/* Importação da fonte moderna Outfit do Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

/* ═══════════════════════════════════════════════════════════
   TEMA ESCURO (padrão)
═══════════════════════════════════════════════════════════ */
:root {
    --bg-primary: #0b0b0b;          /* Preto fosco corporativo */
    --bg-secondary: #141414;        /* Grafite profundo */
    --bg-card: #1c1c1c;             /* Grafite médio */
    --bg-input: #242424;            /* Grafite claro para inputs */
    --bg-blocked: #101010;          /* Fundo mais escuro para campos bloqueados */
    --accent-gold: #c5a880;         /* Dourado metálico refinado */
    --accent-gold-glow: rgba(197, 168, 128, 0.4);
    --accent-gold-dark: #8e734c;    /* Dourado mais fechado */
    --border-color: #2b2b2b;        /* Linhas de divisão sutis */
    --border-highlight: #3d3d3d;
    --text-primary: #f5f5f5;        /* Branco suave */
    --text-secondary: #a0a0a0;      /* Cinza médio */
    --text-muted: #666666;          /* Cinza escuro */
    --login-bg: radial-gradient(circle at center, #181818 0%, #080808 100%);
    --table-hover: rgba(255, 255, 255, 0.02);
    --table-selected: rgba(197, 168, 128, 0.08);
    --search-bg: #171717;

    /* Estados */
    --status-pending-bg: rgba(197, 168, 128, 0.1);
    --status-pending-text: #c5a880;
    --status-qualified-bg: rgba(46, 204, 113, 0.1);
    --status-qualified-text: #2ecc71;
    --status-error-bg: rgba(231, 76, 60, 0.15);
    --status-error-text: #e74c3c;

    --font-primary: 'Outfit', sans-serif;
    --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* ═══════════════════════════════════════════════════════════
   TEMA CLARO
═══════════════════════════════════════════════════════════ */
[data-theme="light"] {
    --bg-primary: #f4f3f0;          /* Off-white corporativo */
    --bg-secondary: #ffffff;        /* Branco puro */
    --bg-card: #f9f8f6;             /* Branco levemente aquecido */
    --bg-input: #eeecea;            /* Input cinza-bege claro */
    --bg-blocked: #e3e0da;          /* Fundo mais escuro para campos bloqueados no light */
    --accent-gold: #9a7a50;         /* Dourado mais rico (contraste no claro) */
    --accent-gold-glow: rgba(154, 122, 80, 0.3);
    --accent-gold-dark: #7a5e38;    /* Dourado fechado */
    --border-color: #ddd9d4;        /* Divisores sutis */
    --border-highlight: #c9c4be;
    --text-primary: #1a1a1a;        /* Quase preto */
    --text-secondary: #5a5a5a;      /* Cinza médio-escuro */
    --text-muted: #8a8a8a;          /* Cinza claro */
    --login-bg: radial-gradient(circle at center, #f4f3f0 0%, #e8e6e1 100%);
    --table-hover: rgba(0, 0, 0, 0.02);
    --table-selected: rgba(154, 122, 80, 0.08);
    --search-bg: #f0ede9;

    /* Estados (mantidos funcionais) */
    --status-pending-bg: rgba(154, 122, 80, 0.1);
    --status-pending-text: #7a5e38;
    --status-qualified-bg: rgba(39, 174, 96, 0.1);
    --status-qualified-text: #1e8449;
    --status-error-bg: rgba(192, 57, 43, 0.1);
    --status-error-text: #c0392b;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-primary);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

/* Layout Geral: Barra Lateral + Conteúdo Principal */
.sidebar {
    width: 260px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.8rem 1.2rem;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar .brand {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--accent-gold);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar .brand span.brand-text {
    color: var(--text-primary);
}

/* Custom Scroll no Menu */
.sidebar nav {
    flex-grow: 1;
    overflow-y: auto;
    margin-bottom: 1rem;
    padding-right: 2px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.sidebar nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar nav::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 4px;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.3rem; /* Espaçamento menor entre itens */
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.5rem 0.8rem; /* Padding reduzido */
    border-radius: 8px;
    font-weight: 500;
    transition: var(--transition-smooth);
}

.nav-item a:hover, .nav-item.active a {
    color: var(--text-primary);
    background-color: var(--bg-card);
    border-left: 3px solid var(--accent-gold);
}

/* Ajuste no espaçamento do submenu */
.nav-item ul {
    gap: 0.3rem !important;
}

.main-content {
    margin-left: 260px;
    flex-grow: 1;
    padding: 2.5rem;
    min-width: 0; /* Impede que o flex quebre layouts longos */
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* CSS para Sidebar Recolhido */
.sidebar.collapsed {
    width: 75px;
    padding: 1.8rem 0.5rem;
}

.sidebar.collapsed .brand {
    justify-content: center;
}

.sidebar.collapsed .brand-text,
.sidebar.collapsed .user-info-sidebar,
.sidebar.collapsed .nav-item a span,
.sidebar.collapsed .nav-item ul {
    display: none !important;
}

.sidebar.collapsed .nav-item a {
    justify-content: center;
    padding: 0.6rem 0;
    gap: 0;
}

.sidebar.collapsed #sidebar-toggle {
    transform: rotate(180deg);
}

.main-content.collapsed {
    margin-left: 75px;
}

/* Cabeçalho da página */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-title h1 {
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.page-title p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.3rem;
}

/* Tenant Selector no Header */
.tenant-badge {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 0.6rem 1.2rem;
    border-radius: 30px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tenant-badge .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--accent-gold);
    box-shadow: 0 0 8px var(--accent-gold);
}

/* KPIs rápidos em Cards */
.kpi-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.kpi-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    transition: var(--transition-smooth);
}

.kpi-card:hover {
    border-color: var(--border-highlight);
    transform: translateY(-2px);
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background-color: var(--accent-gold);
}

.kpi-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    margin: 0.5rem 0 0.2rem 0;
    color: var(--text-primary);
}

.kpi-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Estrutura Master-Detail */
.master-detail-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    transition: var(--transition-smooth);
}

@media (min-width: 1024px) {
    .master-detail-container.panel-open {
        grid-template-columns: 1.2fr 0.8fr;
    }
}

/* Seção Master (Listagem) */
.master-panel {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

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

.panel-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

/* Tabelas */
.table-wrapper {
    overflow-x: auto;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

.custom-table th {
    color: var(--text-secondary);
    font-weight: 500;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.custom-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    transition: var(--transition-smooth);
}

.custom-table tbody tr {
    cursor: pointer;
    transition: var(--transition-smooth);
}

.custom-table tbody tr:hover {
    background-color: var(--table-hover);
}

.custom-table tbody tr.selected {
    background-color: var(--table-selected);
}

/* Badges de Status */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    border-radius: 30px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge.pending {
    background-color: var(--status-pending-bg);
    color: var(--status-pending-text);
    border: 1px solid rgba(197, 168, 128, 0.2);
}

.badge.qualified {
    background-color: var(--status-qualified-bg);
    color: var(--status-qualified-text);
    border: 1px solid rgba(46, 204, 113, 0.2);
}

/* Seção Detail (Painel Expansível) */
.detail-panel {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    display: none; /* Oculto por padrão, ativado via JS */
    flex-direction: column;
    animation: slideInRight 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    height: fit-content;
    position: sticky;
    top: 2.5rem;
}

.detail-panel.active {
    display: flex;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}

.detail-header h3 {
    font-size: 1.2rem;
    font-weight: 600;
}

.close-detail-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.close-detail-btn:hover {
    color: var(--text-primary);
}

/* Conteúdo Rico do Detail */
.detail-group {
    margin-bottom: 1.5rem;
}

.detail-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.detail-value {
    font-size: 1.05rem;
    font-weight: 500;
}

.detail-value.highlight-gold {
    color: var(--accent-gold);
    font-weight: 700;
    font-size: 1.3rem;
}

/* Botões corporativos */
.btn-container {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.btn {
    flex: 1;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    font-family: var(--font-primary);
    transition: var(--transition-smooth);
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--accent-gold);
    color: var(--bg-primary);
}

.btn-primary:hover {
    background-color: #d8b88d;
    box-shadow: 0 0 15px rgba(197, 168, 128, 0.4);
}

.btn-secondary {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: var(--bg-card);
    border-color: var(--border-highlight);
}

/* Animações */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Formulário de Simulação de Intercâmbio */
.exchange-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    margin-top: 2rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-control {
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.8rem 1rem;
    border-radius: 8px;
    font-family: var(--font-primary);
    font-size: 0.9rem;
    transition: var(--transition-smooth);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-gold);
    box-shadow: 0 0 8px rgba(197, 168, 128, 0.2);
}

.form-control[readonly],
.form-control:disabled {
    background-color: var(--bg-blocked);
    border-color: var(--border-color);
    color: var(--text-muted);
    opacity: 0.85;
    cursor: not-allowed;
}

.exchange-preview {
    background-color: var(--bg-primary);
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    padding: 1.2rem;
    margin-bottom: 1.5rem;
}

.exchange-preview-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.exchange-preview-row:last-child {
    margin-bottom: 0;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
    font-weight: 600;
}

/* Régua de Categorias (Gamificação) */
.categories-timeline {
    position: relative;
    width: 100%;
    margin-top: 1rem;
    padding: 1rem 0;
}

.timeline-line {
    position: absolute;
    top: 20px;
    left: 5%;
    width: 90%;
    height: 1px;
    background-color: #3d3d3d;
    z-index: 1;
}

.timeline-nodes {
    display: flex;
    justify-content: space-between;
    position: relative;
    z-index: 2;
}

.timeline-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 15%;
}

.node-circle {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: var(--bg-secondary);
    border: 2px solid var(--accent-gold);
    transition: var(--transition-smooth);
    cursor: pointer;
    position: relative;
    box-shadow: 0 0 0 4px var(--bg-secondary);
}

.node-circle:hover, .node-circle.active {
    background-color: var(--accent-gold);
    box-shadow: 0 0 0 4px var(--bg-secondary), 0 0 10px var(--accent-gold);
}

.node-label {
    margin-top: 1.2rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--accent-gold);
    line-height: 1.2;
}

.node-value {
    margin-top: 0.3rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Abas do Ranking */
.ranking-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    gap: 0.5rem;
}

.ranking-tab {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 1rem 1.5rem;
    font-family: var(--font-primary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    position: relative;
    bottom: -1px;
}

.ranking-tab:hover {
    color: var(--text-primary);
}

.ranking-tab.active {
    color: var(--accent-gold);
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-bottom-color: var(--bg-secondary);
}

/* Barra de Pesquisa */
.search-container {
    display: flex;
    margin-bottom: 1.5rem;
    width: 100%;
}

.search-container .form-control {
    flex-grow: 1;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    background-color: var(--search-bg);
}

.search-btn {
    background-color: var(--accent-gold);
    color: var(--bg-primary);
    border: none;
    padding: 0 1.5rem;
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-btn:hover {
    background-color: #d8b88d;
}

/* Medalha de Ranking */
.medal-icon-container {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: rgba(197, 168, 128, 0.1);
    border: 1.5px solid var(--accent-gold);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.medal-icon {
    color: var(--accent-gold);
    font-size: 1.1rem;
}

/* ─── Botão Primary Global ─────────────────────────────────────────────── */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, var(--accent-gold) 0%, var(--accent-gold-dark) 100%);
    color: #0b0b0b;
    font-weight: 700;
    font-size: 0.88rem;
    padding: 0.6rem 1.4rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition-smooth);
    white-space: nowrap;
}
.btn-primary:hover {
    filter: brightness(1.12);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(197, 168, 128, 0.3);
}
.btn-primary:active { transform: translateY(0); }

/* ─── Catálogo de Recompensas ──────────────────────────────────────────── */
.catalogo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.item-card {
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}
.item-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0,0,0,0.4);
    border-color: rgba(197,168,128,0.4) !important;
}
.item-card.destaque {
    box-shadow: 0 0 0 1px rgba(197,168,128,0.25), 0 8px 24px rgba(0,0,0,0.3);
}

/* ─── Modal de Resgate ─────────────────────────────────────────────────── */
#modal-resgate {
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════
   PILL SWITCH — Toggle Dark / Light Mode
═══════════════════════════════════════════════════════════ */

/* Botão wrapper (sem estilo nativo de button) */
.theme-switch {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
    flex-shrink: 0;
}

/* Trilho da pill */
.theme-switch-track {
    position: relative;
    width: 60px;
    height: 30px;
    border-radius: 15px;
    background: linear-gradient(135deg, #0d1b2a 0%, #1a2a3a 100%);
    border: 1.5px solid rgba(197, 168, 128, 0.35);
    transition: background 0.4s ease, border-color 0.4s ease, box-shadow 0.3s ease;
    overflow: hidden;
}

.theme-switch:hover .theme-switch-track {
    border-color: var(--accent-gold);
    box-shadow: 0 0 10px var(--accent-gold-glow);
}

[data-theme="light"] .theme-switch-track {
    background: linear-gradient(135deg, #dce8f5 0%, #c8dff0 100%);
    border-color: rgba(154, 122, 80, 0.4);
}

/* Ícones do trilho (lua à esquerda, sol à direita) */
.theme-switch-track::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 18% 50%, rgba(255,255,255,0.06) 2px, transparent 2px),
        radial-gradient(circle at 35% 30%, rgba(255,255,255,0.04) 1.5px, transparent 1.5px),
        radial-gradient(circle at 25% 70%, rgba(255,255,255,0.05) 1px, transparent 1px);
    transition: opacity 0.4s ease;
}
[data-theme="light"] .theme-switch-track::before {
    opacity: 0;
}

/* Thumb deslizante */
.theme-switch-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: linear-gradient(135deg, #c5a880 0%, #8e734c 100%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5), 0 0 6px rgba(197, 168, 128, 0.3);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
                background 0.4s ease,
                box-shadow 0.4s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #0b0b0b;
    z-index: 2;
}

[data-theme="light"] .theme-switch-thumb {
    transform: translateX(30px);
    background: linear-gradient(135deg, #f0c060 0%, #d4943a 100%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2), 0 0 8px rgba(240, 192, 96, 0.4);
}

.theme-switch-thumb i {
    font-size: 12px;
    line-height: 1;
    transition: opacity 0.3s ease;
    color: #1a0e00;
}

/* Transição suave de todos os elementos ao trocar tema */
*,
*::before,
*::after {
    transition-property: background-color, border-color, color, box-shadow;
    transition-duration: 0.3s;
    transition-timing-function: ease;
}

/* Exceção: elementos com animação própria não devem herdar transition genérica */
.theme-switch-thumb,
.theme-switch-track,
.btn,
.btn-primary,
.kpi-card,
.nav-item a,
.detail-panel,
.node-circle,
.item-card {
    transition: var(--transition-smooth);
}

.theme-switch-thumb {
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
                background 0.4s ease,
                box-shadow 0.4s ease !important;
}
