:root {
    /* Cores Premium SaaS - Dark Theme */
    --bg-base: #0f172a;
    --bg-panel: rgba(30, 41, 59, 0.7);
    --bg-panel-hover: rgba(51, 65, 85, 0.8);
    --border-color: rgba(255, 255, 255, 0.1);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent-primary: #3b82f6;
    --accent-hover: #2563eb;
    
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --wpp-color: #25D366;
    
    --radius-lg: 16px;
    --radius-md: 8px;
    
    --shadow-glass: 0 4px 30px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    background-image: 
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.1) 0px, transparent 50%);
    background-attachment: fixed;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: rgba(15, 23, 42, 0.6);
    border-right: 1px solid var(--border-color);
    backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    position: fixed;
    height: 100vh;
    z-index: 10;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.sidebar.collapsed {
    width: 80px;
}

.sidebar-header {
    padding: 0 24px 32px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.sidebar-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.sidebar-header h2 .logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
    transition: opacity 0.2s;
    white-space: nowrap;
}

.sidebar-header h2 i.logo-icon {
    color: var(--accent-primary);
}

.sidebar-toggle-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.2s;
    padding: 4px;
}

.sidebar-toggle-btn:hover {
    color: var(--text-primary);
}

.sidebar.collapsed .sidebar-header h2 .logo-area {
    opacity: 0;
    width: 0;
    pointer-events: none;
}

.sidebar.collapsed .sidebar-header {
    padding: 0 0 32px 0;
    display: flex;
    justify-content: center;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 16px;
}

.sidebar-nav a {
    text-decoration: none;
    color: var(--text-secondary);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.sidebar-nav a span {
    flex-grow: 1;
}

.sidebar-nav a i {
    font-size: 1.1rem;
    min-width: 20px;
    text-align: center;
}

/* Drag Handle — Pequeno, discreto, aparece no hover */
.drag-handle {
    cursor: grab;
    color: var(--text-muted);
    font-size: 0.75rem !important; /* Sobrescreve qualquer herança */
    opacity: 0.4;
    transition: opacity 0.2s, color 0.2s;
    flex-shrink: 0;
}
.ad-card:hover .drag-handle {
    opacity: 1;
    color: var(--text-secondary);
}
.drag-handle:active {
    cursor: grabbing;
}

.sidebar-nav a:hover, .sidebar-nav a.active {
    background: var(--bg-panel-hover);
    color: var(--text-primary);
}

.sidebar-nav a.active {
    border-left: 3px solid var(--accent-primary);
    background: rgba(59, 130, 246, 0.1);
}

.sidebar.collapsed .sidebar-nav a {
    justify-content: center;
    padding: 12px;
}

.sidebar.collapsed .sidebar-nav a span {
    display: none;
}

.sidebar-nav a.active {
    border-left: 3px solid var(--accent-primary);
    background: rgba(59, 130, 246, 0.1);
}

/* Contadores da Sidebar (Menu) */
.menu-counter {
    margin-left: auto;
    background: rgba(59, 130, 246, 0.08);
    color: #60a5fa;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    border: 1px solid rgba(59, 130, 246, 0.2);
    transition: all 0.2s ease, opacity 0.3s ease;
    min-width: 20px;
    text-align: center;
    opacity: 0;
}

.menu-counter.loaded {
    opacity: 1;
}

.sidebar-nav a:hover .menu-counter {
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
    border-color: rgba(59, 130, 246, 0.35);
}

.sidebar-nav a.active .menu-counter {
    background: rgba(59, 130, 246, 0.25);
    color: #ffffff;
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.4);
}

.sidebar.collapsed .sidebar-nav a .menu-counter {
    display: none;
}

/* Sidebar Footer & Lixeira */
.sidebar-footer {
    margin-top: auto;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-start;
    transition: padding 0.3s ease;
}

.sidebar.collapsed .sidebar-footer {
    padding: 16px 0;
    justify-content: center;
}

.btn-lixeira {
    color: var(--text-muted);
    font-size: 1.15rem;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    text-decoration: none;
    border: 1px solid transparent;
}

.btn-lixeira:hover, .btn-lixeira.active {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger) !important;
    border-color: rgba(239, 68, 68, 0.3);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.15);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 40px;
    max-width: 1400px;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed ~ .main-content {
    margin-left: 80px;
}

.header-section {
    margin-bottom: 32px;
}

.header-section h1, .header-section h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-section h2 {
    font-size: 1.5rem;
    margin-top: 48px;
}

.header-section p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.mt-2 { margin-top: 48px; }

/* Glass Panels */
.glass-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-glass);
}

/* Painel de Controle */
.control-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 32px;
}

.status-idle { color: var(--text-secondary); }
.status-running { color: var(--success); animation: pulse 2s infinite; }

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Botões */
.btn-primary, .btn-secondary, .btn-star {
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-star {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.btn-star:hover {
    background: rgba(245, 158, 11, 0.2);
    transform: translateY(-2px);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
    transform: translateY(-2px);
}

.btn-obs {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-primary);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.btn-obs:hover {
    background: rgba(59, 130, 246, 0.2);
    transform: translateY(-2px);
}

/* ── Esteira: grid de dias (5 colunas → D6 cai sob D1) ── */
.days-grid {
    display: grid;
    grid-template-columns: repeat(5, 58px);
    gap: 6px 10px;
}

.day-cell-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.day-label-small {
    font-size: 0.68rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 2px;
    letter-spacing: 0.3px;
}

.day-input {
    width: 58px;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 4px;
    border-radius: var(--radius-md);
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    transition: border-color 0.2s;
    -moz-appearance: textfield;
}

.day-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: rgba(0,0,0,0.35);
}

.day-input::-webkit-outer-spin-button,
.day-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Grid de Cards */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 24px;
}

.ad-card {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: transform 0.3s ease, opacity 0.3s ease;
    position: relative;
}

.ad-card:hover {
    transform: translateY(-5px);
    border-color: rgba(255,255,255,0.2);
}

/* List View Styles */
.cards-grid.list-view {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cards-grid.list-view .ad-card {
    flex-direction: row !important;
    align-items: flex-start !important;
    padding: 16px 24px;
    gap: 20px;
}

.cards-grid.list-view .ad-card:hover {
    transform: translateX(4px) translateY(0);
}

.cards-grid.list-view .ad-card-header {
    flex: 0 0 220px;
    flex-direction: column;
    align-items: flex-start;
    border-bottom: none !important;
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
    gap: 6px;
    border-right: 1px solid var(--border-color);
    padding-right: 20px;
    margin-right: 4px;
}

.cards-grid.list-view .tracking-days-container {
    flex: 1;
    align-content: flex-start;
    margin-bottom: 0 !important;
}

.cards-grid.list-view .ad-actions {
    flex: 0 0 auto;
    flex-direction: column;
    border-top: none !important;
    padding-top: 0 !important;
    margin-top: 0 !important;
    align-self: stretch;
    justify-content: center;
    gap: 6px;
}

.cards-grid.list-view .ad-actions a,
.cards-grid.list-view .ad-actions button {
    flex: none !important;
    width: 120px;
    font-size: 0.8rem;
    padding: 7px 10px;
}

.cards-grid.list-view .ad-card-header h3 {
    font-size: 1rem;
}

.ad-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.ad-card-header h3 {
    font-size: 1.2rem;
    color: var(--text-primary);
    line-height: 1.4;
}

.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 700;
}

.wpp-badge {
    background: rgba(37, 211, 102, 0.15);
    color: var(--wpp-color);
    border: 1px solid rgba(37, 211, 102, 0.3);
}

.wpp-badge-small {
    background: rgba(37, 211, 102, 0.15);
    color: var(--wpp-color);
    font-size: 0.7rem;
    padding: 2px 4px;
    border-radius: 4px;
    margin-left: 8px;
}

.ad-stats {
    display: flex;
    gap: 24px;
    background: rgba(0, 0, 0, 0.2);
    padding: 12px 16px;
    border-radius: var(--radius-md);
}

.stat-box {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.text-sm { font-size: 0.9rem; font-weight: 500; }
.text-xs { font-size: 0.8rem; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }

.ad-text-preview {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
    flex: 1;
}

.ad-actions {
    display: flex;
    gap: 12px;
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.ad-actions a, .ad-actions button {
    flex: 1;
    justify-content: center;
    font-size: 0.9rem;
    padding: 10px;
}

/* Empty State */
.empty-state {
    padding: 64px 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.empty-state i {
    font-size: 3rem;
    color: var(--text-muted);
}

.empty-state h3 {
    font-size: 1.5rem;
}

.empty-state p {
    color: var(--text-secondary);
}

/* Tabela de Acompanhamento */
.table-container {
    overflow-x: auto;
    padding: 24px;
}

.tracking-table {
    width: 100%;
    border-collapse: collapse;
}

.tracking-table th, .tracking-table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

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

.offer-col { width: 26%; }
.day-col { width: 11%; text-align: center; }
.actions-col { width: 16%; text-align: center; min-width: 140px; }

.tracking-table td {
    vertical-align: middle;
}

.day-cell {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 40px;
}

.day-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.day-input-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.day-input-group input {
    width: 60px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px;
    border-radius: var(--radius-md);
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
}

.day-input-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: rgba(0, 0, 0, 0.4);
}

/* Ocultar setas do input number */
.day-input-group input::-webkit-outer-spin-button,
.day-input-group input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.btn-icon {
    color: var(--text-secondary);
    background: rgba(255,255,255,0.05);
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: rgba(255,255,255,0.15);
    color: white;
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 16px 24px;
    border-radius: var(--radius-md);
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    color: white;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 9999;
    backdrop-filter: blur(12px);
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-success { border-left: 4px solid var(--success); }
.toast-success i { color: var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-error i { color: var(--danger); }

/* Modal Manual */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    width: 400px;
    padding: 30px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.form-input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px;
    border-radius: var(--radius-md);
    font-size: 1rem;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: rgba(0, 0, 0, 0.4);
}

.card-day-input {
    width: 44px;
    text-align: center;
    font-size: 0.8rem;
    padding: 4px 2px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 4px;
    font-weight: 600;
    -moz-appearance: textfield;
}

.card-day-input::-webkit-outer-spin-button,
.card-day-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ==========================================================================
   Estilos Responsivos para Dispositivos Móveis (Celulares / iPhones)
   ========================================================================== */

/* Componentes de Header Móvel e Backdrop */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
}

.mobile-menu-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
}

.mobile-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.mobile-logo i {
    color: var(--accent-primary);
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }
    
    .sidebar-backdrop {
        display: block;
    }
    
    /* Configuração Drawer da Sidebar */
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        z-index: 1001;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        background: rgba(15, 23, 42, 0.95);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        width: 280px;
    }
    
    .sidebar.open {
        left: 0;
    }
    
    /* Esconde botão toggle padrão da sidebar no mobile */
    .sidebar-toggle-btn {
        display: none;
    }
    
    /* Conteúdo Principal */
    .main-content {
        margin-left: 0 !important;
        padding: 16px;
        padding-top: 80px; /* Compensa o header de 60px + folga */
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }
    
    /* Adaptação de Títulos e Cabeçalhos */
    .header-section {
        margin-bottom: 20px;
    }
    
    .header-section h1, .header-section h2 {
        font-size: 1.5rem;
    }
    
    .header-section p {
        font-size: 0.95rem;
    }
    
    /* Painéis e Controladores */
    .control-panel {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
        padding: 16px 20px;
    }
    
    .panel-actions {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    
    .panel-actions button {
        width: 100%;
        justify-content: center;
        margin-right: 0 !important;
    }
    
    /* Grid de Cards */
    .cards-grid {
        grid-template-columns: 1fr; /* Força 1 coluna nos celulares */
        gap: 16px;
    }
    
    .ad-card {
        padding: 16px;
    }
    
    /* Modais */
    .modal-content {
        width: 92% !important;
        max-width: 420px;
        padding: 20px !important;
        border-radius: var(--radius-lg);
    }
    
    /* Font size min 16px para iOS não dar zoom automático */
    .form-input, select, textarea, .day-input, .day-input-group input, .card-day-input {
        font-size: 16px !important;
    }
    
    .card-day-input {
        width: 48px !important;
        padding: 6px 2px !important;
    }
    
    /* Otimizações da Esteira de Acompanhamento no Mobile */
    .days-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px;
    }
    
    /* Tabelas em modo scroll se houver tabelas em outros locais */
    .table-container {
        padding: 12px;
        border-radius: var(--radius-md);
    }
    
    .tracking-table th, .tracking-table td {
        padding: 10px 8px;
        font-size: 0.85rem;
    }
}
