/* ============================================================
   PLAYOUT HUB - Estilos do Sistema
   Design moderno, responsivo, dark theme profissional
   Mobile-first + Desktop
   ============================================================ */

/* ---- Reset & Base ---- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #6C5CE7;
    --primary-light: #A29BFE;
    --primary-dark: #4834D4;
    --secondary: #00CEC9;
    --accent: #FD79A8;
    --bg-dark: #0F0F1A;
    --bg-card: #1A1A2E;
    --bg-card-alt: #16213E;
    --bg-input: #222244;
    --text-primary: #FFFFFF;
    --text-secondary: #B2B2CC;
    --text-muted: #6C6C8A;
    --border: #2A2A4A;
    --success: #00B894;
    --warning: #FDCB6E;
    --danger: #E17055;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s ease;
    --sidebar-width: 260px;
}

/* Tema claro */
[data-theme="light"] {
    --bg-dark: #E8E8F0;
    --bg-card: #FFFFFF;
    --bg-card-alt: #F0F0F8;
    --bg-input: #E0E0EE;
    --text-primary: #1A1A2E;
    --text-secondary: #4A4A6A;
    --text-muted: #6C6C8A;
    --border: #D0D0E0;
    --shadow: 0 4px 24px rgba(0,0,0,0.08);
}

.theme-toggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 1.25rem;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: var(--transition);
}
.theme-toggle:hover {
    background: var(--primary);
    color: #fff;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    width: 100%;
}

a {
    color: var(--primary-light);
    text-decoration: none;
    transition: var(--transition);
}
a:hover {
    color: var(--secondary);
}

/* ---- Layout Principal ---- */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: transform 0.3s ease, visibility 0.3s;
}

.sidebar-header {
    padding: 0 1.5rem 1.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}

.sidebar-header h1 {
    font-size: 1.4rem;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.sidebar-header .subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.sidebar-nav {
    list-style: none;
    flex: 1;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.sidebar-nav li a:hover,
.sidebar-nav li a.active {
    background: rgba(108, 92, 231, 0.1);
    color: var(--primary-light);
    border-left-color: var(--primary);
}

.sidebar-nav li a .icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ---- Sidebar Backdrop (Mobile) ---- */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99;
}

.sidebar-backdrop.active {
    display: block;
}

/* ---- Main Content ---- */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 2rem;
    min-height: 100vh;
    min-width: 0; /* previne overflow em flex */
    max-width: 100%;
}

/* ---- Page Header ---- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h2 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.page-header .badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 206, 201, 0.15);
    color: var(--secondary);
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
}

.page-header .badge .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--secondary);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ---- Cards de Métricas ---- */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: var(--transition);
}

.metric-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.metric-card .metric-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
}

.metric-card .metric-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.metric-card .metric-icon {
    float: right;
    font-size: 1.3rem;
    opacity: 0.6;
}

.metric-card.primary .metric-value { color: var(--primary-light); }
.metric-card.secondary .metric-value { color: var(--secondary); }
.metric-card.accent .metric-value { color: var(--accent); }
.metric-card.warning .metric-value { color: var(--warning); }

/* ---- Cards / Painéis ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ---- Grid de Gráficos ---- */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.chart-container {
    position: relative;
    height: 280px;
    width: 100%;
}

/* Galeria Photobooth — 1 linha, carrossel com setas */
.galeria-carousel-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    position: relative;
}
.galeria-carousel {
    flex: 1;
    overflow: hidden;
    min-width: 0;
}
.galeria-grid {
    display: flex;
    flex-wrap: nowrap;
    gap: 1rem;
    padding: 0.25rem 0;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}
.galeria-grid::-webkit-scrollbar {
    height: 6px;
}
.galeria-grid::-webkit-scrollbar-track {
    background: var(--bg-input);
    border-radius: 3px;
}
.galeria-grid::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
.galeria-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-card-alt);
    color: var(--text-primary);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}
.galeria-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.galeria-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.galeria-item {
    flex: 0 0 auto;
    width: 140px;
    height: 140px;
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-input);
}
.galeria-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.galeria-item .galeria-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.35rem 0.5rem;
    font-size: 0.7rem;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- Tabelas ---- */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -1.25rem;
    padding: 0 1.25rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    min-width: 600px; /* permite scroll horizontal se necessário */
}

table thead {
    background: var(--bg-card-alt);
}

table th {
    padding: 10px 12px;
    text-align: left;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

table tbody tr {
    transition: var(--transition);
}

table tbody tr:hover {
    background: rgba(108, 92, 231, 0.05);
}

table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

/* ---- Mobile Cards View (tabelas responsivas) ---- */
.mobile-cards {
    display: none;
}

.mobile-card-item {
    background: var(--bg-card-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.mobile-card-item .mobile-card-title {
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.mobile-card-item .mobile-card-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 0.8rem;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}

.mobile-card-item .mobile-card-row:last-child {
    border-bottom: none;
}

.mobile-card-item .mobile-card-label {
    color: var(--text-muted);
}

.mobile-card-item .mobile-card-value {
    color: var(--text-secondary);
    text-align: right;
}

.mobile-card-item .mobile-card-actions {
    display: flex;
    gap: 6px;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

/* Ranking position */
.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: 700;
}

.rank-1 { background: linear-gradient(135deg, #FFD700, #FFA500); color: #000; }
.rank-2 { background: linear-gradient(135deg, #C0C0C0, #A0A0A0); color: #000; }
.rank-3 { background: linear-gradient(135deg, #CD7F32, #A0522D); color: #FFF; }
.rank-other { background: var(--bg-card-alt); color: var(--text-muted); }
.rank-other { background: var(--bg-card-alt); color: var(--text-muted); }

/* ---- Botões ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    min-height: 40px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #FFF;
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4);
}
.btn-primary:active {
    transform: scale(0.97);
}

.btn-secondary {
    background: var(--bg-card-alt);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    border-color: var(--primary);
    color: var(--primary-light);
}

.btn-success {
    background: var(--success);
    color: #FFF;
}
.btn-success:hover {
    background: #00A884;
}

.btn-danger {
    background: var(--danger);
    color: #FFF;
}
.btn-danger:hover {
    background: #D63031;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.75rem;
    min-height: 32px;
}

.btn-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* ---- Formulários ---- */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 16px; /* previne zoom no iOS */
    transition: var(--transition);
    -webkit-appearance: none;
    appearance: none;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.2);
}

select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236C6C8A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

/* ---- Barra de Busca ---- */
.search-bar {
    position: relative;
    margin-bottom: 1rem;
}

.search-bar input {
    width: 100%;
    padding: 10px 14px 10px 40px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 16px;
    -webkit-appearance: none;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary);
}

.search-bar .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

/* ---- Login Page ---- */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-dark);
    padding: 1rem;
}

.login-box {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
}

.login-box h1 {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-box .login-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 2rem;
}

/* ---- Alertas ---- */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.85rem;
    word-break: break-word;
}

.alert-success {
    background: rgba(0, 184, 148, 0.15);
    color: var(--success);
    border: 1px solid rgba(0, 184, 148, 0.3);
}

.alert-danger {
    background: rgba(225, 112, 85, 0.15);
    color: var(--danger);
    border: 1px solid rgba(225, 112, 85, 0.3);
}

.alert-warning {
    background: rgba(253, 203, 110, 0.15);
    color: var(--warning);
    border: 1px solid rgba(253, 203, 110, 0.3);
}

/* ---- Modal ---- */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    width: 100%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
    -webkit-overflow-scrolling: touch;
}

.modal h3 {
    margin-bottom: 1.25rem;
    font-size: 1.1rem;
}

/* ---- Status Badge ---- */
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-ativo {
    background: rgba(0, 184, 148, 0.15);
    color: var(--success);
}

.status-encerrado {
    background: rgba(225, 112, 85, 0.15);
    color: var(--danger);
}

.status-pausado {
    background: rgba(253, 203, 110, 0.15);
    color: var(--warning);
}

/* ---- Feedback Stars ---- */
.star-rating {
    display: flex;
    gap: 4px;
    direction: rtl;
    justify-content: flex-end;
}

.star-rating input {
    display: none;
}

.star-rating label {
    font-size: 2rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.star-rating label:hover,
.star-rating label:hover ~ label,
.star-rating input:checked ~ label {
    color: var(--warning);
}

/* ---- Utilities ---- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.d-flex { display: flex; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.flex-wrap { flex-wrap: wrap; }
.hidden { display: none !important; }
.w-100 { width: 100%; }

/* ---- Mobile Menu Button ---- */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 200;
    background: var(--primary);
    color: #FFF;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    font-size: 1.3rem;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    align-items: center;
    justify-content: center;
}

/* ---- UUID code display ---- */
.uuid-code {
    background: var(--bg-input);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
    font-family: 'Consolas', 'Courier New', monospace;
    word-break: break-all;
    display: inline-block;
    max-width: 100%;
}

/* ============================================================
   RESPONSIVO - TABLET (max 1024px)
   ============================================================ */
@media (max-width: 1024px) {
    .main-content {
        padding: 1.5rem;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   RESPONSIVO - MOBILE (max 768px)
   ============================================================ */
@media (max-width: 768px) {
    /* Sidebar: escondida por padrão, overlay no mobile */
    .sidebar {
        transform: translateX(-100%);
        visibility: hidden;
        box-shadow: none;
    }

    .sidebar.open {
        transform: translateX(0);
        visibility: visible;
        box-shadow: 4px 0 20px rgba(0,0,0,0.5);
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
        padding-top: 3.5rem; /* espaço para o botão do menu */
    }

    .mobile-menu-btn {
        display: flex;
    }

    /* Page header */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .page-header h2 {
        font-size: 1.4rem;
    }

    .page-header .d-flex {
        width: 100%;
        flex-direction: column;
    }

    .page-header select.form-control {
        width: 100% !important;
        min-width: 0 !important;
    }

    /* Métricas: 2 colunas no mobile */
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .metric-card {
        padding: 1rem;
    }

    .metric-card .metric-value {
        font-size: 1.5rem;
    }

    .metric-card .metric-label {
        font-size: 0.65rem;
    }

    .metric-card .metric-icon {
        font-size: 1.1rem;
    }

    /* Gráficos: 1 coluna */
    .charts-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .chart-container {
        height: 220px;
    }

    /* Cards */
    .card {
        padding: 1rem;
        border-radius: 10px;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .card-header .btn-group {
        width: 100%;
    }

    .card-header .btn-group .btn {
        flex: 1;
    }

    /* Tabela: usar layout de cards no mobile */
    .table-wrapper {
        margin: 0;
        padding: 0;
    }

    .desktop-table {
        display: none;
    }

    .mobile-cards {
        display: block;
    }

    /* Botões */
    .btn-group {
        width: 100%;
    }

    /* Modal */
    .modal {
        padding: 1.25rem;
        max-height: 90vh;
    }

    .modal .btn-group {
        flex-direction: column;
    }

    .modal .btn-group .btn {
        width: 100%;
    }

    /* Login */
    .login-box {
        padding: 1.5rem;
    }

    .login-box h1 {
        font-size: 1.3rem;
    }
}

/* ============================================================
   RESPONSIVO - MOBILE PEQUENO (max 480px)
   ============================================================ */
@media (max-width: 480px) {
    body {
        font-size: 14px;
    }

    .main-content {
        padding: 0.75rem;
        padding-top: 3.5rem;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .metric-card {
        padding: 0.75rem;
    }

    .metric-card .metric-value {
        font-size: 1.3rem;
    }

    .chart-container {
        height: 200px;
    }

    .card {
        padding: 0.75rem;
        margin-bottom: 1rem;
    }

    .page-header h2 {
        font-size: 1.2rem;
    }
}

/* ---- Loading Spinner ---- */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---- Skeleton Loading ---- */
.skeleton {
    background: linear-gradient(90deg, var(--bg-card-alt) 25%, var(--border) 50%, var(--bg-card-alt) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ---- Tooltip ---- */
.copy-tooltip {
    position: fixed;
    background: var(--success);
    color: #FFF;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    pointer-events: none;
    z-index: 9999;
    animation: fadeInOut 1.5s forwards;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateY(5px); }
    20% { opacity: 1; transform: translateY(0); }
    80% { opacity: 1; }
    100% { opacity: 0; }
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
#toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 400px;
    width: calc(100% - 2rem);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    transform: translateX(120%);
    transition: transform 0.3s ease;
    pointer-events: auto;
    backdrop-filter: blur(10px);
}

.toast.toast-show {
    transform: translateX(0);
}

.toast-success {
    background: rgba(0, 184, 148, 0.95);
    color: #FFF;
}

.toast-error {
    background: rgba(225, 112, 85, 0.95);
    color: #FFF;
}

.toast-warning {
    background: rgba(253, 203, 110, 0.95);
    color: #000;
}

.toast-info {
    background: rgba(108, 92, 231, 0.95);
    color: #FFF;
}

.toast-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.3rem;
    cursor: pointer;
    opacity: 0.7;
    padding: 0 4px;
    flex-shrink: 0;
}

.toast-close:hover {
    opacity: 1;
}

/* ============================================================
   LOGIN TABS (melhorado)
   ============================================================ */
.login-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
}

.login-tab {
    flex: 1;
    padding: 10px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.3s;
    min-height: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    background: var(--bg-input);
    color: var(--text-muted);
}

.login-tab.active {
    background: var(--primary);
    color: #FFF;
}

/* ============================================================
   FORM VALIDATION
   ============================================================ */
.form-error {
    display: block;
    color: var(--danger);
    font-size: 0.75rem;
    margin-top: 4px;
    min-height: 0;
}

.form-control.is-invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(225, 112, 85, 0.2);
}

/* ============================================================
   INPUT GROUP (password toggle)
   ============================================================ */
.input-group {
    display: flex;
    gap: 0;
}

.input-group .form-control {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    flex: 1;
}

.input-group-btn {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-left: none;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 12px;
    font-size: 1rem;
    transition: var(--transition);
    min-width: 44px;
}

.input-group-btn:hover {
    background: var(--bg-card-alt);
    color: var(--text-primary);
}

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-bar .form-group {
    margin-bottom: 0;
    flex: 1;
    min-width: 150px;
}

.filter-bar .form-group label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.filter-bar .form-control {
    font-size: 0.8rem;
    padding: 8px 12px;
}

/* ============================================================
   AUDITORIA TABLE
   ============================================================ */
.audit-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.audit-badge.admin { background: rgba(108, 92, 231, 0.2); color: var(--primary-light); }
.audit-badge.cliente { background: rgba(0, 206, 201, 0.2); color: var(--secondary); }
.audit-badge.sistema { background: rgba(253, 203, 110, 0.2); color: var(--warning); }

/* ============================================================
   HR Separator
   ============================================================ */
hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1rem 0;
}

/* ============================================================
   PERFIL PAGE
   ============================================================ */
.profile-card {
    background: var(--bg-card-alt);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    margin-bottom: 1.5rem;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 1rem;
}

.profile-name {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.profile-email {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ============================================================
   CONFIGURAÇÃO DE CAMPOS - Admin
   ============================================================ */

/* Grid de grupos de campos */
.campos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    padding: 0.5rem 0;
}

.campos-grupo {
    background: var(--bg-card-alt);
    border-radius: 12px;
    padding: 1.2rem;
    border: 1px solid var(--border);
}

.campos-grupo-titulo {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-light);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Checkbox simples (label com texto) */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: normal;
}
.checkbox-label input[type="checkbox"] {
    margin: 0;
}

/* Checkbox customizado */
.campo-checkbox {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.4rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
}

.campo-checkbox:hover {
    background: rgba(108, 92, 231, 0.08);
}

.campo-checkbox input[type="checkbox"] {
    display: none;
}

.campo-checkmark {
    width: 20px;
    height: 20px;
    min-width: 20px;
    border: 2px solid var(--border);
    border-radius: 5px;
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.campo-checkbox input[type="checkbox"]:checked + .campo-checkmark {
    background: var(--primary);
    border-color: var(--primary);
}

.campo-checkbox input[type="checkbox"]:checked + .campo-checkmark::after {
    content: '✓';
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
}

.campo-label {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.campo-slug {
    font-size: 0.65rem;
    padding: 2px 6px;
    background: rgba(108, 92, 231, 0.15);
    color: var(--primary-light);
    border-radius: 4px;
    font-family: monospace;
}

/* Alert info */
.alert-info {
    background: rgba(0, 206, 201, 0.1);
    border: 1px solid rgba(0, 206, 201, 0.25);
    color: var(--secondary);
    padding: 1rem 1.2rem;
    border-radius: 10px;
    font-size: 0.85rem;
    line-height: 1.5;
}

/* ============================================================
   RESPONSIVE ADDITIONS
   ============================================================ */
@media (max-width: 768px) {
    #toast-container {
        right: 0.5rem;
        top: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    .filter-bar {
        flex-direction: column;
    }

    .filter-bar .form-group {
        min-width: 100%;
    }

    .campos-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   BARRA DE CAPTAÇÃO EM TEMPO REAL
   ============================================================ */
.captacao-bar {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1.25rem;
    margin-bottom: 1.5rem;
    align-items: center;
    justify-content: center;
}

.captacao-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.captacao-label {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.captacao-value {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.captacao-unit {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.tendencia-up { color: #00B894 !important; }
.tendencia-down { color: #E17055 !important; }
.tendencia-stable { color: var(--text-muted) !important; }

/* Pulse animation quando há atividade */
.captacao-bar.active-pulse {
    animation: pulseBorder 2s infinite;
}

@keyframes pulseBorder {
    0%, 100% { border-color: var(--border); }
    50% { border-color: var(--primary); box-shadow: 0 0 12px rgba(108, 92, 231, 0.2); }
}

/* ============================================================
   CARDS DE GAMIFICAÇÃO AVANÇADA
   ============================================================ */
#gamificacao-grid .metric-card {
    border-left: 3px solid var(--card-color, var(--primary));
}

/* ============================================================
   BARRA COMPARATIVO HOJE vs ONTEM
   ============================================================ */
.comparativo-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
}

.comparativo-item {
    text-align: center;
}

.comparativo-label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.comparativo-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.comparativo-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.5rem;
}

.comparativo-variacao {
    font-size: 0.9rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 20px;
    white-space: nowrap;
}

.var-up {
    background: rgba(0, 184, 148, 0.15);
    color: #00B894;
}

.var-down {
    background: rgba(225, 112, 85, 0.15);
    color: #E17055;
}

.var-stable {
    background: rgba(178, 178, 204, 0.1);
    color: var(--text-muted);
}

/* ============================================================
   HEATMAP DE ATIVIDADE
   ============================================================ */
.heatmap-wrapper {
    padding: 0.5rem 0;
}

.heatmap-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.5rem;
}

.heatmap-grid {
    display: inline-flex;
    flex-direction: column;
    gap: 2px;
    min-width: max-content;
}

.heatmap-row {
    display: flex;
    gap: 2px;
    align-items: center;
}

.heatmap-label {
    width: 40px;
    min-width: 40px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-align: right;
    padding-right: 6px;
}

.heatmap-hour-label {
    width: 32px;
    min-width: 32px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.55rem;
    color: var(--text-muted);
}

.heatmap-cell {
    width: 32px;
    min-width: 32px;
    height: 32px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    cursor: default;
    transition: transform 0.15s, box-shadow 0.15s;
}

.heatmap-cell:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 2;
    position: relative;
}

.heatmap-legend {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: flex-end;
    padding-top: 0.75rem;
    margin-right: 0.5rem;
}

.heatmap-legend-cell {
    width: 18px;
    height: 18px;
    border-radius: 3px;
}

/* ============================================================
   RESPONSIVE — Novas métricas
   ============================================================ */
@media (max-width: 768px) {
    .captacao-bar {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.75rem;
    }

    .comparativo-bar {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.75rem;
    }

    .heatmap-cell {
        width: 24px;
        min-width: 24px;
        height: 24px;
        font-size: 0.5rem;
    }

    .heatmap-hour-label {
        width: 24px;
        min-width: 24px;
        font-size: 0.45rem;
    }

    .heatmap-label {
        width: 30px;
        min-width: 30px;
        font-size: 0.6rem;
    }
}

@media (max-width: 480px) {
    .heatmap-cell {
        width: 18px;
        min-width: 18px;
        height: 18px;
        font-size: 0;
    }

    .heatmap-hour-label {
        width: 18px;
        min-width: 18px;
    }
}