/* ============= RESET E VARIÁVEIS ============= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --primary-color: #667eea;
    --primary-dark: #5568d3;
    --secondary-color: #764ba2;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --text-dark: #1f2937;
    --text-light: #6b7280;
    --bg-light: #f9fafb;
    --border-color: #e5e7eb;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #d6d6d7;
    min-height: 100vh;
    color: var(--text-dark);
}

/* ============= SIDEBAR ============= */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: white;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    z-index: 1000;
}

/* Desktop: sidebar sempre visível, sem colapsar */
.sidebar.collapsed {
    width: var(--sidebar-width);
}

.sidebar.collapsed .sidebar-header {
    padding: 20px;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 70px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 16px;
    color: var(--primary-color);
    white-space: nowrap;
    overflow: hidden;
    flex: 1;
    min-width: 0;
}

.logo-icon {
    font-size: 28px;
    min-width: 28px;
    flex-shrink: 0;
}

.logo-text {
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.3s ease, width 0.3s ease;
}

.sidebar.collapsed .logo-text {
    opacity: 0;
    width: 0;
}

.sidebar-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: none; /* Oculto por padrão no desktop */
    flex-direction: column;
    gap: 4px;
    transition: all 0.3s ease;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-light);
    transition: all 0.3s ease;
}

.sidebar-toggle:hover span {
    background: var(--primary-color);
}

.sidebar.collapsed .sidebar-toggle span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.sidebar.collapsed .sidebar-toggle span:nth-child(2) {
    opacity: 0;
}

.sidebar.collapsed .sidebar-toggle span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* Navegação */
.sidebar-nav {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--text-light);
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
}

.nav-item:hover {
    background: var(--bg-light);
    color: var(--primary-color);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.1) 0%, transparent 100%);
    color: var(--primary-color);
    font-weight: 600;
    border-right: 3px solid var(--primary-color);
}

.nav-icon {
    font-size: 20px;
    min-width: 20px;
    text-align: center;
}

.sidebar.collapsed .nav-text {
    opacity: 0;
    width: 0;
}

.nav-divider {
    height: 1px;
    background: var(--border-color);
    margin: 15px 20px;
}

.sidebar.collapsed .nav-divider {
    margin: 15px 10px;
}

/* Footer do Sidebar */
.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-light);
    text-align: center;
}

.current-date {
    font-weight: 500;
}

.sidebar.collapsed .sidebar-footer {
    padding: 15px 5px;
    font-size: 10px;
}

/* ============= MAIN CONTENT ============= */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
    padding: 30px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* ============= HEADER ============= */
.header {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: var(--shadow-md);
    margin-bottom: 30px;
    text-align: center;
}

.header h1 {
    font-size: 32px;
    background: linear-gradient(135deg, #0013b9 0%, #000061 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

.header p {
    color: var(--text-light);
    font-size: 14px;
}

/* ============= QUICK ACTIONS (Removido da página, mantido para compatibilidade) ============= */
.quick-actions {
    display: none;
}

/* ============= STATS ROW ============= */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-box {
    background: white;    
    padding: 30px;
    border-radius: 15px;
    box-shadow: var(--shadow-md);
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-box:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.stat-box.highlight {
    background: linear-gradient(135deg, #0015b1 0%, #000075 100%);
    color: white;
    border: 6px solid white;
}

.stat-number {
    font-size: 48px;
    font-weight: 700;
    margin-bottom: 10px;
}

.stat-label {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.8;
}

.percentage-badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    padding: 5px 15px;
    border-radius: 20px;
    margin-top: 10px;
    font-weight: 600;
}

/* ============= DASHBOARD GRID ============= */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

.card {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: var(--shadow-md);
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--bg-light);
}

/* ============= TERMÔMETRO ============= */
.chart-container {
    position: relative;
    height: 350px;
    padding: 10px 0;
}

.thermometer-container {
    padding: 20px 0;
}

.thermometer-label {
    text-align: center;
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 15px;
}

.thermometer {
    width: 100%;
    height: 40px;
    background: var(--bg-light);
    border-radius: 20px;
    overflow: hidden;
    position: relative;
}

.thermometer-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px;
    transition: width 1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    min-width: 50px;
}

/* ============= RANKING ============= */
.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: var(--bg-light);
    border-radius: 10px;
    transition: all 0.2s ease;
}

.ranking-item:hover {
    background: #f3f4f6;
    transform: translateX(5px);
}

.ranking-position {
    width: 35px;
    height: 35px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.ranking-info {
    flex: 1;
}

.ranking-name {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.ranking-stats {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 13px;
    color: var(--text-light);
}

.ranking-stat {
    white-space: nowrap;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* ============= MODAL ============= */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 15px!important;
    width: 100%;
    max-width: 600px;
    max-height: 90vh!important;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 24px;
    color: var(--text-dark);
}

.btn-close {
    background: transparent;
    border: none;
    font-size: 30px;
    color: var(--text-light);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-close:hover {
    color: var(--danger-color);
    transform: rotate(90deg);
}

/* ============= FORMULÁRIO ============= */
.form-group {
    padding: 20px 25px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-dark);
    font-size: 14px;
}

.required {
    color: var(--danger-color);
}

.form-group input[type="text"],
.form-group input[type="tel"],
.form-group input[type="date"],
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group input:disabled,
.form-group textarea:disabled {
    background: var(--bg-light);
    cursor: not-allowed;
}

.form-group textarea {
    min-height: 80px;
    resize: vertical;
}

/* ============= BUSCA ============= */
.search-results {
    max-height: 200px;
    overflow-y: auto;
    margin-top: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: none;
}

.search-results:not(:empty) {
    display: block;
}

.search-result-item {
    padding: 12px 15px;
    cursor: pointer;
    transition: background 0.2s ease;
    border-bottom: 1px solid var(--border-color);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--bg-light);
}

.result-name {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.result-info {
    font-size: 13px;
    color: var(--text-light);
}

/* ============= HISTÓRICO DE PRESENÇAS ============= */
.historico-presencas {
    margin: 0 25px 20px;
    padding: 20px;
    background: var(--bg-light);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid white;
}

.total-presencas {
    background: var(--primary-color);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.history-month {
    margin-bottom: 15px;
}

.month-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 10px;
    text-transform: capitalize;
}

.month-days {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.day-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow);
    transition: all 0.2s ease;
}

.day-badge:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.day-weekday {
    font-size: 10px;
    color: var(--text-light);
    text-transform: uppercase;
}

.day-number {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-color);
}

.loading-history,
.empty-history,
.error-history {
    text-align: center;
    padding: 20px;
    color: var(--text-light);
}

.error-history {
    color: var(--danger-color);
}

/* ============= LISTA DE DATAS ============= */
.dates-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 15px;
    background: var(--bg-light);
    border-radius: 8px;
    min-height: 60px;
}

.dates-list.empty {
    display: flex;
    align-items: center;
    justify-content: center;
}

.date-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 8px 12px;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.date-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-dark);
}

.btn-remove-date {
    background: var(--danger-color);
    color: white;
    border: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s ease;
}

.btn-remove-date:hover {
    background: #dc2626;
    transform: scale(1.1);
}

.btn-add-date {
    background: var(--success-color);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-add-date:hover {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ============= BOTÕES DE AÇÃO ============= */
.form-actions {
    display: flex;
    gap: 10px;
    padding: 20px 25px;
    border-top: 1px solid var(--border-color);
}

.btn-cancel,
.btn-submit {
    flex: 1;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-cancel {
    background: var(--bg-light);
    color: var(--text-dark);
}

.btn-cancel:hover {
    background: #e5e7eb;
}

.btn-submit {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ============= MENSAGENS ============= */
.message {
    margin: 0 25px 20px;
    padding: 15px;
    border-radius: 8px;
    font-size: 14px;
}

.message.hidden {
    display: none;
}

.message.success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}

.message.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

.message.warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #f59e0b;
}

.message.info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #3b82f6;
}

/* ============= ESTADOS ============= */
.loading,
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
}

/* ============= RESPONSIVO ============= */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    /* Mobile: sidebar oculto por padrão */
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    /* Mobile: mostrar botão hamburguer */
    .sidebar-toggle {
        display: flex !important;
    }
    
    .sidebar-header {
        justify-content: space-between;
    }
    
    .main-content {
        margin-left: 0;
        padding: 20px;
    }
    
    .sidebar.collapsed ~ .main-content {
        margin-left: 0;
    }
    
    .stats-row {
        grid-template-columns: 1fr;
    }
    
    .header h1 {
        font-size: 24px;
    }
    
    .stat-number {
        font-size: 36px;
    }
}

@media (max-width: 480px) {
    .modal-content {
        max-width: 100%;
        border-radius: 0;
        max-height: 100vh;
    }
    
    .month-days {
        justify-content: center;
    }
    
    .form-actions {
        flex-direction: column;
    }
}

/* Estilos para o seletor de período */
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.chart-title {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
}

.period-selector {
    display: flex;
    gap: 8px;
    background: #f3f4f6;
    padding: 4px;
    border-radius: 8px;
}

.period-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: #6b7280;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.period-btn:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.period-btn.active {
    background: #667eea;
    color: white;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

/* Seletor de data customizado */
.custom-date-selector {
    display: flex;
    gap: 8px;
    align-items: center;
    background: #f9fafb;
    padding: 8px;
    border-radius: 8px;
    border: 2px solid #e5e7eb;
}

.date-input {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    color: #374151;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
}

.date-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.date-separator {
    color: #6b7280;
    font-size: 13px;
    font-weight: 500;
}

.btn-apply-date {
    padding: 8px 16px;
    background: #10b981;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-apply-date:hover {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
}

.btn-clear-date {
    padding: 8px 12px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-clear-date:hover {
    background: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

@media (max-width: 1024px) {
    .chart-controls {
        align-items: stretch;
        width: 100%;
    }

    .period-selector {
        width: 100%;
        justify-content: space-between;
    }

    .custom-date-selector {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 768px) {
    .chart-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .chart-controls {
        width: 100%;
    }

    .period-selector {
        flex-wrap: wrap;
    }

    .period-btn {
        flex: 1;
        min-width: calc(33.333% - 6px);
        padding: 10px 8px;
        font-size: 13px;
    }

    .custom-date-selector {
        flex-wrap: wrap;
    }

    .date-input {
        flex: 1;
        min-width: 120px;
    }

    .date-separator {
        display: none;
    }

    .btn-apply-date,
    .btn-clear-date {
        flex: 1;
    }
}

