/**
 * Painel do Afiliado — layout isolado do tema HSSites
 * Não usa --hs-sidebar-* para evitar menu invisível
 */

.aff-body {
    margin: 0;
    min-height: 100vh;
    background: #f1f5f9;
    font-family: 'Roboto', system-ui, sans-serif;
    color: #0f172a;
}

.aff-body * {
    box-sizing: border-box;
}

/* Sidebar fixa e legível */
.aff-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 200;
    width: 260px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #0f172a;
    color: #e2e8f0;
    border-right: 1px solid #1e293b;
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.18);
}

.aff-sidebar-brand {
    padding: 22px 20px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
}

.aff-sidebar-brand a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.aff-logo {
    max-height: 42px;
    max-width: 170px;
    width: auto;
    height: auto;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

.aff-brand-tag {
    display: inline-block;
    margin-top: 10px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(57, 170, 180, 0.18);
    color: #7dd3e0;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.aff-nav {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px 20px;
}

.aff-nav-label {
    margin: 14px 10px 8px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #64748b;
}

.aff-nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    margin-bottom: 4px;
    border-radius: 10px;
    color: #cbd5e1 !important;
    text-decoration: none !important;
    font-size: 0.92rem;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
}

.aff-nav-link i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    color: #94a3b8;
}

.aff-nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff !important;
}

.aff-nav-link:hover i {
    color: #7dd3e0;
}

.aff-nav-link.is-active {
    background: linear-gradient(135deg, rgba(57, 170, 180, 0.22), rgba(14, 165, 233, 0.18));
    color: #ffffff !important;
    font-weight: 600;
    box-shadow: inset 3px 0 0 #39aab4;
}

.aff-nav-link.is-active i {
    color: #7dd3e0;
}

.aff-sidebar-foot {
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.aff-logout:hover {
    background: rgba(239, 68, 68, 0.15) !important;
    color: #fecaca !important;
}

.aff-logout:hover i {
    color: #f87171 !important;
}

/* Área principal */
.aff-main {
    margin-left: 260px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.aff-topbar {
    position: sticky;
    top: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 68px;
    padding: 12px 28px;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
}

.aff-topbar-left,
.aff-topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.aff-page-title {
    margin: 0 !important;
    font-family: 'Montserrat', sans-serif;
    font-size: 1.15rem !important;
    font-weight: 700 !important;
    color: #0f172a !important;
    line-height: 1.3;
}

.aff-menu-btn {
    display: none;
    width: 40px;
    height: 40px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
    color: #0f172a;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.aff-btn-learn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.28);
}

.aff-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 6px 6px;
    border-radius: 999px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.aff-avatar {
    width: 34px !important;
    height: 34px !important;
    border-radius: 50%;
    background: #39aab4 !important;
    color: #fff !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    float: none !important;
}

.aff-user-name {
    font-size: 0.84rem;
    font-weight: 600;
    color: #334155;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.aff-content {
    padding: 24px 28px 48px;
    width: 100%;
    max-width: 1280px;
}

.aff-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 190;
}

.aff-backdrop.is-visible {
    display: block;
}

/* Cards utilitários do painel */
.aff-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 22px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    margin-bottom: 20px;
}

.aff-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.aff-card-head h2,
.aff-card-head h3 {
    margin: 0;
    font-family: 'Montserrat', sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 10px;
}

.aff-card-head p {
    margin: 6px 0 0;
    color: #64748b;
    font-size: 0.9rem;
    line-height: 1.5;
    max-width: 720px;
}

.aff-benefit-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.aff-benefit {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px 16px;
}

.aff-benefit strong {
    display: block;
    font-size: 0.92rem;
    color: #0f172a;
    margin-bottom: 4px;
}

.aff-benefit span {
    font-size: 0.8rem;
    color: #64748b;
    line-height: 1.4;
}

.aff-benefit.is-green {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.aff-benefit.is-blue {
    background: #eff6ff;
    border-color: #bfdbfe;
}

.aff-benefit.is-violet {
    background: #f5f3ff;
    border-color: #ddd6fe;
}

.aff-code-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 12px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
}

.aff-code-pill code {
    background: #dbeafe;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.9rem;
}

.aff-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.aff-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.aff-filter-btn {
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #475569;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.aff-filter-btn:hover {
    border-color: #39aab4;
    color: #0f766e;
}

.aff-filter-btn.is-active {
    background: #0f172a;
    border-color: #0f172a;
    color: #ffffff;
}

.aff-search {
    position: relative;
    min-width: 220px;
    flex: 1;
    max-width: 320px;
}

.aff-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 0.85rem;
}

.aff-search input {
    width: 100%;
    padding: 10px 12px 10px 36px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #ffffff;
    font-size: 0.88rem;
    color: #0f172a;
}

.aff-search input:focus {
    outline: none;
    border-color: #39aab4;
    box-shadow: 0 0 0 3px rgba(57, 170, 180, 0.15);
}

.aff-pages-grid,
.aff-services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.aff-page-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 14px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 16px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.aff-page-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    transform: translateY(-1px);
}

.aff-page-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.aff-page-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.aff-page-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
    white-space: nowrap;
}

.aff-page-card h4 {
    margin: 10px 0 6px;
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
    font-family: 'Montserrat', sans-serif;
}

.aff-page-card p {
    margin: 0;
    color: #64748b;
    font-size: 0.82rem;
    line-height: 1.45;
    min-height: 2.4em;
}

.aff-link-box {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 6px;
}

.aff-link-box input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    font-size: 0.72rem;
    color: #475569;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    padding: 6px 8px;
}

.aff-link-box button {
    border: none;
    background: #e2e8f0;
    color: #334155;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
}

.aff-link-box button:hover {
    background: #cbd5e1;
}

.aff-card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.aff-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 8px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 700;
    text-decoration: none !important;
    border: none;
    cursor: pointer;
    transition: filter 0.15s ease, transform 0.1s ease;
}

.aff-action:hover {
    filter: brightness(1.05);
}

.aff-action:active {
    transform: scale(0.98);
}

.aff-action-primary {
    background: #0f172a;
    color: #ffffff !important;
}

.aff-action-wa {
    background: #25d366;
    color: #ffffff !important;
}

.aff-action-ghost {
    grid-column: 1 / -1;
    background: #f8fafc;
    color: #334155 !important;
    border: 1px solid #e2e8f0;
}

.aff-section-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.aff-section-tab {
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #475569;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
}

.aff-section-tab.is-active {
    background: #39aab4;
    border-color: #39aab4;
    color: #ffffff;
}

.aff-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: #94a3b8;
    padding: 36px 16px;
}

/* Compat: páginas antigas ainda usam .sales-table / .stats-grid */
.aff-body .sales-table,
.aff-body .referral-box,
.aff-body .stat-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.aff-body .sales-table {
    padding: 22px;
}

.aff-body .stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.aff-body .stat-card {
    padding: 20px;
}

.aff-body .stat-card h3 {
    margin: 0 0 8px;
    font-size: 0.85rem;
    color: #64748b;
    font-weight: 500;
}

.aff-body .stat-card .value {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 800;
    color: #0f172a;
    font-family: 'Montserrat', sans-serif;
}

.aff-body .stat-card .icon {
    float: right;
    opacity: 0.18;
    font-size: 1.8rem;
}

.aff-body .referral-box {
    padding: 22px;
    margin-top: 8px;
}

.aff-body .referral-link {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.aff-body .referral-link input {
    flex: 1;
    min-width: 200px;
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
    font-weight: 600;
}

.aff-body .loading {
    text-align: center;
    padding: 40px;
    color: #64748b;
}

.aff-body table {
    width: 100%;
    border-collapse: collapse;
}

.aff-body th {
    text-align: left;
    padding: 12px;
    background: #f8fafc;
    font-weight: 600;
    color: #475569;
}

.aff-body td {
    padding: 12px;
    border-bottom: 1px solid #e2e8f0;
    color: #334155;
}

@media (max-width: 980px) {
    .aff-benefit-grid {
        grid-template-columns: 1fr;
    }

    .aff-menu-btn {
        display: inline-flex;
    }

    .aff-sidebar {
        transform: translateX(-105%);
        transition: transform 0.25s ease;
    }

    .aff-sidebar.is-open {
        transform: translateX(0);
    }

    .aff-main {
        margin-left: 0;
    }

    .aff-content {
        padding: 18px 16px 40px;
    }

    .aff-topbar {
        padding: 12px 16px;
    }

    .aff-user-name {
        display: none;
    }

    .aff-btn-learn span {
        display: none;
    }
}

@media (max-width: 640px) {
    .aff-pages-grid,
    .aff-services-grid {
        grid-template-columns: 1fr;
    }

    .aff-page-title {
        font-size: 1rem !important;
    }
}
