:root {
    --bg-primary: #0a0f1d;
    --bg-card: #141e33;
    --bg-sidebar: #0d1527;
    --accent-yellow: #f59e0b;
    --accent-blue: #2563eb;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --text-light: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #1e293b;
    --sidebar-width-collapsed: 70px;
    --sidebar-width-expanded: 260px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-light);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

.app-container {
    display: flex;
    width: 100%;
    min-height: 100vh;
    position: relative;
}

/* ==========================================
   SIDEBAR (DESKTOP)
   ========================================== */
.sidebar {
    width: var(--sidebar-width-collapsed);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    overflow-x: hidden;
    overflow-y: auto;
    flex-shrink: 0;
    box-shadow: 4px 0 10px rgba(0, 0, 0, 0.3);
}

.sidebar.expanded {
    width: var(--sidebar-width-expanded);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 15px 12px;
    border-bottom: 1px solid var(--border-color);
    height: 70px;
    position: relative;
    overflow: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    justify-content: flex-start;
    overflow: hidden;
}

.sidebar-logo-img {
    width: 38px;
    height: 38px;
    object-fit: contain;
    flex-shrink: 0;
    filter: drop-shadow(0 0 4px rgba(245, 158, 11, 0.3));
    margin: 0 auto;
    cursor: pointer;
}

.sidebar.expanded .sidebar-logo-img {
    margin: 0;
}

.sidebar-logo-text {
    color: var(--accent-yellow);
    font-weight: bold;
    font-size: 1.1rem;
    white-space: nowrap;
    display: none;
    overflow: hidden;
}

.sidebar.expanded .sidebar-logo-text {
    display: block;
}

.toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 5px;
    border-radius: 6px;
    margin-left: auto;
}

.sidebar.expanded .toggle-btn {
    display: flex;
}

.toggle-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* NAVEGAÇÃO SIDEBAR */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 15px 8px;
    flex: 1;
    overflow: hidden;
}

.nav-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 12px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    width: 100%;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar.expanded .nav-item {
    justify-content: flex-start;
    padding: 12px 15px;
}

.nav-item svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
    flex-shrink: 0;
}

.nav-text {
    display: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar.expanded .nav-text {
    display: inline-block;
}

.nav-item:hover {
    background-color: var(--bg-card);
    color: var(--accent-yellow);
}

.nav-item.active {
    background-color: var(--accent-yellow);
    color: #000;
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.4);
}

.mobile-only-item {
    display: none;
}

.sidebar-footer {
    padding: 15px 8px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
}

.user-profile-sidebar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px 10px;
    color: var(--text-muted);
    overflow: hidden;
}

.sidebar.expanded .user-profile-sidebar {
    justify-content: flex-start;
}

.user-avatar-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar:not(.expanded) .nav-text,
.sidebar:not(.expanded) .sidebar-logo-text {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    width: 0 !important;
}

/* ==========================================
   CONTEÚDO PRINCIPAL
   ========================================== */
.main-content {
    flex: 1;
    padding: 20px 30px;
    overflow-y: auto;
    max-width: 1400px;
    margin-left: var(--sidebar-width-collapsed);
    width: calc(100% - var(--sidebar-width-collapsed));
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.expanded + .main-content {
    margin-left: var(--sidebar-width-expanded);
    width: calc(100% - var(--sidebar-width-expanded));
}

header {
    text-align: center;
    padding: 20px 0;
    border-bottom: 2px solid var(--accent-yellow);
    margin-bottom: 25px;
    background: linear-gradient(180deg, rgba(245, 158, 11, 0.1) 0%, rgba(10, 15, 29, 0) 100%);
}

.header-title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.brasao-prf-img {
    height: 90px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 0 8px rgba(245, 158, 11, 0.4));
}

header h1 {
    color: var(--accent-yellow);
    font-size: 2.2rem;
    letter-spacing: 1.5px;
}

header p {
    color: var(--text-muted);
    font-style: italic;
    margin-top: 8px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* CARDS DE MÉTRICAS */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.card {
    background-color: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.card h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    text-transform: uppercase;
}

.card .metric {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--accent-yellow);
}

/* ==========================================
   AVATAR K9 REATIVO E DINÂMICO
   ========================================== */
.avatar-box {
    display: flex;
    align-items: center;
    gap: 20px;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 2px solid var(--border-color);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 25px;
    transition: all 0.3s ease;
}

.avatar-box.raiva {
    border-color: var(--accent-red);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
}
.avatar-box.triste {
    border-color: var(--accent-blue);
    box-shadow: 0 0 15px rgba(37, 99, 235, 0.4);
}
.avatar-box.feliz {
    border-color: var(--accent-yellow);
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.4);
}

.avatar-img-container {
    width: 90px;
    height: 90px;
    min-width: 90px;
    border-radius: 50%;
    border: 3px solid var(--accent-blue);
    overflow: hidden;
    flex-shrink: 0;
    transition: border-color 0.3s ease;
}

.avatar-box.raiva .avatar-img-container { border-color: var(--accent-red); }
.avatar-box.triste .avatar-img-container { border-color: var(--accent-blue); }
.avatar-box.feliz .avatar-img-container { border-color: var(--accent-yellow); }

.avatar-k9-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-status h4 {
    font-size: 1.2rem;
    margin-bottom: 5px;
    transition: color 0.3s ease;
}

.avatar-box.raiva .avatar-status h4 { color: var(--accent-red); }
.avatar-box.triste .avatar-status h4 { color: #38bdf8; }
.avatar-box.feliz .avatar-status h4 { color: var(--accent-yellow); }

.avatar-status p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* GRÁFICOS E GALERIA */
.charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.chart-card {
    background-color: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color);
}

.gallery-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.gallery-item {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    height: 160px;
    border: 1px solid var(--border-color);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-caption {
    position: absolute;
    bottom: 0;
    background: rgba(10, 15, 29, 0.85);
    color: var(--text-light);
    width: 100%;
    padding: 8px;
    font-size: 0.8rem;
    text-align: center;
    font-weight: bold;
}

.section-title {
    color: var(--accent-blue);
    margin: 25px 0 15px 0;
    border-left: 4px solid var(--accent-blue);
    padding-left: 10px;
    font-size: 1.3rem;
}

/* TABELAS E FORMULÁRIOS DESKTOP */
table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--bg-card);
    border-radius: 8px;
    overflow: hidden;
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: #0a0f1d;
    color: var(--accent-yellow);
    font-size: 0.9rem;
    text-transform: uppercase;
}

input[type="number"], input[type="text"], input[type="date"], input[type="password"] {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-light);
    padding: 8px 12px;
    border-radius: 6px;
    width: 100%;
    font-size: 0.95rem;
}

.btn-action {
    background-color: var(--accent-blue);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s;
}

.btn-action:hover {
    background-color: #1d4ed8;
}

.stars { color: var(--accent-yellow); }

/* ==========================================
   ESTILOS DO MODAL DE CONFIGURAÇÕES
   ========================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.modal-overlay.active {
    display: flex;
}

.modal-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 90%;
    max-width: 420px;
    padding: 24px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.modal-header h3 {
    color: var(--accent-yellow);
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-close-modal {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.avatar-upload-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.avatar-preview-box {
    position: relative;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    border: 3px solid var(--accent-blue);
}

.avatar-preview-box img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.btn-upload-icon {
    position: absolute;
    bottom: 0;
    right: 0;
    background: var(--accent-blue);
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.85rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

.avatar-upload-container small {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.modal-divider {
    border: 0;
    border-top: 1px solid var(--border-color);
    margin: 18px 0;
}

.sub-title {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.btn-cancel {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
}

/* ==========================================
   ADAPTAÇÃO RESPONSIVA FIXA PARA SMARTPHONES
   ========================================== */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    /* BARRA INFERIOR FIXA NO RODAPÉ */
    .sidebar {
        width: 100% !important;
        height: 65px !important;
        position: fixed !important;
        bottom: 0 !important;
        top: auto !important;
        left: 0 !important;
        right: 0 !important;
        border-right: none !important;
        border-top: 1px solid var(--border-color) !important;
        flex-direction: row !important;
        justify-content: space-around !important;
        align-items: center !important;
        background-color: var(--bg-sidebar) !important;
        backdrop-filter: blur(12px);
        z-index: 9999 !important;
        box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.5);
        padding: 0 !important;
    }

    .sidebar-header,
    .sidebar-footer { 
        display: none !important; 
    }

    .sidebar-nav {
        flex-direction: row !important;
        justify-content: space-around !important;
        align-items: center !important;
        width: 100% !important;
        height: 100% !important;
        padding: 0 4px !important;
        gap: 0 !important;
    }

    .nav-item {
        justify-content: center !important;
        padding: 8px 4px !important;
        border-radius: 8px !important;
        flex: 1 !important;
        height: 100% !important;
    }

    .mobile-only-item {
        display: flex !important;
    }

    .sidebar:not(.expanded) .nav-text {
        display: none !important;
    }

    /* AJUSTE DO CONTEÚDO PRINCIPAL PARA NÃO FICAR ATRÁS DA BARRA INFERIOR */
    .main-content {
        width: 100% !important;
        margin-left: 0 !important;
        padding: 15px 12px 85px 12px !important;
    }

    .sidebar.expanded + .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }

    header h1 { 
        font-size: 1.4rem; 
    }

    .brasao-prf-img { 
        height: 60px; 
    }

    /* ESTILIZAÇÃO DAS TABELAS EM FORMATO CARD NO MOBILE */
    .responsive-card-table table, 
    .responsive-card-table thead, 
    .responsive-card-table tbody, 
    .responsive-card-table tr { 
        display: block; 
        width: 100%;
    }

    .responsive-card-table thead {
        display: none;
    }

    .responsive-card-table tr { 
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: 12px;
        margin-bottom: 16px;
        padding: 16px;
        display: flex;
        flex-direction: column;
        gap: 12px;
        box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    }

    .responsive-card-table td { 
        display: flex;
        flex-direction: column;
        padding: 0;
        border: none;
        width: 100%;
    }

    .responsive-card-table td::before { 
        content: attr(data-label);
        font-size: 0.72rem;
        font-weight: bold;
        color: var(--accent-yellow);
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin-bottom: 4px;
    }

    .responsive-card-table td[data-label="Dia / Turno"],
    .responsive-card-table td[data-label="Exercício"],
    .responsive-card-table td[data-label="Disciplina"],
    .responsive-card-table td[data-label="Tópico"] {
        border-bottom: 1px solid var(--border-color);
        padding-bottom: 8px;
    }

    .responsive-card-table td[data-label="Dia / Turno"] strong,
    .responsive-card-table td[data-label="Disciplina"] strong,
    .responsive-card-table td[data-label="Exercício"] strong {
        font-size: 1.1rem;
        color: var(--text-light);
    }

    .responsive-card-table td[data-label="Disciplinas"] {
        font-size: 1rem;
        color: #e2e8f0;
        font-weight: 600;
        line-height: 1.4;
    }

    .responsive-card-table td[data-label="24 Horas"],
    .responsive-card-table td[data-label="7 Dias"],
    .responsive-card-table td[data-label="30 Dias"] {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        background: rgba(255,255,255,0.03);
        padding: 10px;
        border-radius: 8px;
    }

    .responsive-card-table td[data-label="24 Horas"]::before,
    .responsive-card-table td[data-label="7 Dias"]::before,
    .responsive-card-table td[data-label="30 Dias"]::before {
        margin-bottom: 0;
    }

    .responsive-card-table input[type="checkbox"] {
        width: 24px;
        height: 24px;
        accent-color: var(--accent-yellow);
        cursor: pointer;
    }
}