/* css/affiliate.css - Premium SaaS Dashboard Styles */

:root {
    --aff-bg: #f8fafc;
    --aff-surface: #ffffff;
    --aff-surface-hover: #f1f5f9;
    --aff-border: #e2e8f0;
    
    --aff-text: #0f172a;
    --aff-text-muted: #64748b;
    
    --aff-primary: #4f46e5;
    --aff-primary-hover: #4338ca;
    
    --aff-success: #10b981;
    --aff-warning: #f59e0b;
    --aff-danger: #ef4444;
    --aff-info: #3b82f6;
    
    --aff-grad-blue: linear-gradient(135deg, var(--aff-primary), var(--aff-info));
    
    --aff-card-radius: 16px;
    --aff-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --aff-shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

body.affiliate-layout {
    background-color: var(--aff-bg);
    color: var(--aff-text);
    font-family: 'Tajawal', sans-serif;
    margin: 0;
    display: flex;
    flex-direction: row;
    min-height: 100vh;
    direction: rtl;
}

body.affiliate-layout::before,
body.affiliate-layout::after {
    display: none;
}

/* Sidebar */
.aff-sidebar {
    width: 280px;
    background: var(--aff-surface);
    border-left: 1px solid var(--aff-border);
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 100;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.02);
}

.aff-brand {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--aff-primary);
    margin-bottom: 2.5rem;
    text-align: center;
    text-decoration: none;
    display: block;
    letter-spacing: -0.5px;
}

.aff-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.aff-nav-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.2rem;
    color: var(--aff-text-muted);
    text-decoration: none;
    border-radius: 12px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.aff-nav-link:hover {
    background: var(--aff-surface-hover);
    color: var(--aff-text);
}

.aff-nav-link.active {
    background: var(--aff-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.aff-nav-link.active svg {
    stroke: white;
}

.aff-nav-link svg {
    width: 20px;
    height: 20px;
    stroke: var(--aff-text-muted);
    transition: stroke 0.2s ease;
}

.aff-logout-btn {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    background: transparent;
    color: var(--aff-danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s ease;
    font-family: inherit;
    font-size: 0.9rem;
    width: fit-content;
    align-self: center;
}

.aff-logout-btn:hover {
    background: var(--aff-danger);
    color: white;
}

.aff-logout-btn:hover svg {
    stroke: white;
}

/* Main Content */
.aff-main {
    flex: 1;
    padding: 2.5rem 3.5rem;
    overflow-y: auto;
    max-width: 1400px;
    margin: 0 auto;
}

.aff-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
}

.aff-welcome {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.aff-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--aff-primary), var(--aff-info));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: bold;
    color: white;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

.aff-welcome h1 {
    font-size: 1.8rem;
    font-weight: 800;
    margin: 0 0 0.2rem 0;
    color: var(--aff-text);
}

.aff-welcome p {
    margin: 0;
    color: var(--aff-text-muted);
    font-size: 1rem;
}

.aff-badge {
    background: var(--aff-warning);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: bold;
    color: white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* Stats Grid */
.aff-stats-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem 3rem;
    margin-bottom: 2.5rem;
    align-items: center;
}

.aff-stat-card {
    display: flex;
    flex-direction: column;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
}

.aff-stat-card:hover {
    transform: none;
    box-shadow: none;
}

.aff-stat-card::before {
    display: none;
}

.aff-stat-card.blue .aff-stat-value { color: var(--aff-primary); }
.aff-stat-card.orange .aff-stat-value { color: var(--aff-warning); }
.aff-stat-card.green .aff-stat-value { color: var(--aff-success); }
.aff-stat-card.purple .aff-stat-value { color: #8b5cf6; }

.aff-stat-title {
    color: var(--aff-text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.aff-stat-value {
    font-size: 1.5rem;
    font-weight: 800;
}

/* Action Button */
.aff-btn-primary {
    background: var(--aff-grad-blue);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: opacity 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.aff-btn-primary:hover {
    opacity: 0.9;
}

/* Glassy Tables / Panels */
.aff-panel {
    background: var(--aff-surface);
    border: 1px solid var(--aff-border);
    border-radius: var(--aff-card-radius);
    padding: 2rem;
    backdrop-filter: blur(10px);
    margin-bottom: 3rem;
    overflow-x: auto;
}

.aff-panel-title {
    font-size: 1.4rem;
    margin-bottom: 1.5rem;
    font-weight: 700;
}

.aff-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 600px;
}

.aff-table th, .aff-table td {
    padding: 1.2rem 1rem;
    text-align: right;
    border-bottom: 1px solid var(--aff-border);
}

.aff-table th {
    color: var(--aff-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.aff-table tr:last-child td {
    border-bottom: none;
}

.aff-table tbody tr {
    transition: background 0.3s ease;
}

.aff-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Custom Status Badges */
.aff-status {
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: bold;
    display: inline-block;
}
.aff-status.success { background: rgba(16, 185, 129, 0.1); color: #10b981; }
.aff-status.pending { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }
.aff-status.failed { background: rgba(239, 68, 68, 0.1); color: #ef4444; }

/* Responsive */
@media (max-width: 992px) {
    body.affiliate-layout {
        flex-direction: column;
    }
    .aff-sidebar {
        width: 100%;
        height: auto;
        border-left: none;
        border-bottom: 1px solid var(--aff-border);
        padding: 1rem;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        position: relative;
    }
    .aff-brand {
        margin-bottom: 0;
        font-size: 1.4rem;
    }
    .aff-nav {
        flex-direction: row;
        gap: 1rem;
        flex: unset;
        overflow-x: auto;
    }
    .aff-logout-btn {
        margin-top: 0;
        padding: 0.5rem 1rem;
    }
    .aff-main {
        padding: 1.5rem;
    }
}

@media (max-width: 640px) {
    body.affiliate-layout {
        font-size: 0.95rem;
    }
    /* Top bar: brand + logout always visible, nav scrolls under it */
    .aff-sidebar {
        padding: 0.75rem;
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        position: sticky;
        top: 0;
        background: var(--aff-surface);
        z-index: 100;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    }
    .aff-sidebar .aff-brand {
        font-size: 1.15rem;
        margin-bottom: 0.25rem;
    }
    .aff-nav {
        flex-direction: row;
        gap: 0.4rem;
        flex: unset;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.25rem;
    }
    .aff-nav-link {
        padding: 0.55rem 0.85rem;
        gap: 0.4rem;
        font-size: 0.85rem;
        white-space: nowrap;
        flex-shrink: 0;
    }
    .aff-logout-btn {
        margin-top: 0;
        width: 100%;
        align-self: stretch;
    }
    .aff-main {
        padding: 1rem 0.75rem;
        overflow: visible;
    }
    .aff-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }
    .aff-header > div:last-child {
        width: 100%;
    }
    .aff-welcome {
        gap: 0.75rem;
        flex-wrap: wrap;
    }
    .aff-welcome h1 {
        font-size: 1.25rem;
    }
    .aff-avatar {
        width: 48px;
        height: 48px;
        font-size: 1.3rem;
    }
    .aff-stats-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
        margin-bottom: 1.5rem;
        align-items: stretch;
    }
    .aff-stat-card {
        background: var(--aff-surface);
        border: 1px solid var(--aff-border);
        border-radius: 12px;
        padding: 0.85rem;
        box-shadow: var(--aff-shadow);
    }
    .aff-stat-value {
        font-size: 1.15rem;
    }
    .aff-panel {
        padding: 1rem;
        margin-bottom: 1.5rem;
        border-radius: 14px;
        overflow: visible;
    }
    .aff-panel-title {
        font-size: 1.1rem;
        margin-bottom: 1rem;
    }

    /* Turn the products table into stacked cards on mobile */
    .aff-panel:first-of-type .aff-table,
    .aff-panel .aff-table {
        display: block;
        min-width: 0;
    }
    .aff-table thead {
        display: none;
    }
    .aff-table tbody {
        display: block;
    }
    .aff-table tbody tr {
        display: block;
        border: 1px solid var(--aff-border);
        border-radius: 12px;
        padding: 0.75rem;
        margin-bottom: 0.75rem;
        background: var(--aff-surface);
    }
    .aff-table tbody tr td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
        padding: 0.4rem 0;
        border-bottom: none;
        text-align: right;
    }
    .aff-table tbody tr td::before {
        content: attr(data-label);
        font-size: 0.75rem;
        font-weight: 700;
        color: var(--aff-text-muted);
        flex-shrink: 0;
    }

    .aff-btn-primary {
        padding: 0.65rem 1rem;
        font-size: 0.9rem;
        width: 100%;
        justify-content: center;
    }
    .aff-welcome .aff-badge {
        display: block !important;
        width: fit-content;
    }
    .aff-rewards-grid {
        grid-template-columns: 1fr !important;
    }
}
