/* =============================================
   Visão Docente — Design System
   Minimalista, moderno, ambiente escolar
   ============================================= */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* --- CSS Variables --- */
:root {
    --primary: #1B5E7B;
    --primary-light: #2980B9;
    --primary-dark: #13455A;
    --accent: #27AE60;
    --accent-light: #2ECC71;
    --warning: #F39C12;
    --danger: #E74C3C;
    --danger-light: rgba(231, 76, 60, 0.12);
    --primary-light-bg: rgba(27, 94, 123, 0.1);
    --bg: #F5F7FA;
    --bg-card: #FFFFFF;
    --text: #2C3E50;
    --text-light: #7F8C8D;
    --border: #E0E6ED;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 78px;
    --header-height: 64px;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.1);
    --transition: all 0.2s ease;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

body.no-scroll {
    overflow: hidden;
}

a {
    color: var(--primary-light);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary);
}

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

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 90;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--primary-dark);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: var(--transition);
}

.app-layout.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
}

.sidebar-brand {
    padding: 16px 16px 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.sidebar-brand-text h1 {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.sidebar-brand-text span {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 400;
}

.app-layout.sidebar-collapsed .sidebar-brand {
    padding: 16px 12px;
    justify-content: center;
}

.app-layout.sidebar-collapsed .sidebar-brand-text {
    display: none;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.sidebar-nav .nav-section {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.4);
    padding: 16px 12px 6px;
    font-weight: 600;
}

.app-layout.sidebar-collapsed .sidebar-nav .nav-section {
    display: none;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: rgba(255, 255, 255, 0.75);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
}

.app-layout.sidebar-collapsed .sidebar-nav a {
    justify-content: center;
    padding: 10px;
}

.app-layout.sidebar-collapsed .sidebar-nav a i {
    margin: 0;
}

.app-layout.sidebar-collapsed .sidebar-nav a {
    font-size: 0;
}

.sidebar-nav a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.sidebar-nav a.active {
    background: var(--primary);
    color: #fff;
}

.sidebar-nav a i {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-footer-note {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.55);
    text-align: center;
}

.app-layout.sidebar-collapsed .sidebar-footer {
    padding: 12px;
}

.sidebar-footer .user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-footer .user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
}

.sidebar-footer .user-details {
    flex: 1;
    min-width: 0;
}

.app-layout.sidebar-collapsed .sidebar-footer .user-details {
    display: none;
}

.app-layout.sidebar-collapsed .sidebar-footer .user-avatar {
    display: none;
}

.app-layout.sidebar-collapsed .sidebar-footer .user-info {
    justify-content: center;
}

.sidebar-footer .user-name {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer .user-role {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.5);
    text-transform: capitalize;
}

.user-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}

.app-layout.sidebar-collapsed .user-actions {
    display: none;
}

.user-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.55);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.user-action-btn svg {
    width: 15px;
    height: 15px;
}

.user-action-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    max-width: calc(100vw - var(--sidebar-width));
    overflow-x: hidden;
}

.app-layout.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-width);
    max-width: calc(100vw - var(--sidebar-collapsed-width));
}

/* --- Header --- */
.header {
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-mobile-menu {
    display: none;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text);
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.btn-mobile-menu svg {
    width: 18px;
    height: 18px;
}

.btn-sidebar-toggle {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: rgba(255, 255, 255, 0.5);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.btn-sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.btn-sidebar-toggle svg {
    width: 18px;
    height: 18px;
}

.header-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-menu {
    position: relative;
}

.user-menu-trigger {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fff;
    padding: 4px 10px 4px 4px;
    cursor: pointer;
    transition: var(--transition);
}

.user-menu-trigger:hover {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(41, 128, 185, 0.12);
}

.user-menu-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
}

.user-menu-name {
    max-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.84rem;
    color: var(--text);
    font-weight: 600;
}

.user-menu-trigger i {
    width: 16px;
    height: 16px;
    color: var(--text-light);
}

.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 180px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 8px;
    display: none;
    z-index: 120;
}

.user-menu.open .user-menu-dropdown {
    display: block;
}

.user-menu-dropdown a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 500;
}

.user-menu-dropdown a:hover {
    background: var(--bg);
    color: var(--primary);
}

.user-menu-dropdown a i {
    width: 16px;
    height: 16px;
}

/* --- Page Content --- */
.page-content {
    padding: 28px 32px;
}

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.card-body {
    padding: 24px;
}

/* --- Stat Cards (Dashboard) --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 22px 24px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-card .stat-icon.blue { background: rgba(27, 94, 123, 0.1); color: var(--primary); }
.stat-card .stat-icon.green { background: rgba(39, 174, 96, 0.1); color: var(--accent); }
.stat-card .stat-icon.orange { background: rgba(243, 156, 18, 0.1); color: var(--warning); }
.stat-card .stat-icon.red { background: rgba(231, 76, 60, 0.1); color: var(--danger); }

.stat-card .stat-info h3 {
    font-size: 0.78rem;
    color: var(--text-light);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
    margin-top: 2px;
}

.stat-card .stat-label {
    font-size: 0.78rem;
    color: var(--text-light);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    display: block;
}

.stat-card--danger {
    border-color: var(--danger);
}

/* --- Tables --- */
.table-responsive {
    overflow-x: auto;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

.table-wrapper {
    overflow-x: auto;
}

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

table thead th {
    background: var(--bg);
    padding: 12px 16px;
    text-align: left;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

table tbody td {
    padding: 12px 16px;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

table tbody tr:hover {
    background: rgba(27, 94, 123, 0.03);
}

table tbody tr:last-child td {
    border-bottom: none;
}

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: rgba(39, 174, 96, 0.12); color: #1E8449; }
.badge-warning { background: rgba(243, 156, 18, 0.12); color: #B7770D; }
.badge-danger  { background: rgba(231, 76, 60, 0.12); color: #C0392B; }
.badge-info    { background: rgba(41, 128, 185, 0.12); color: #1B5E7B; }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-light);
}

.btn-accent {
    background: var(--accent);
    color: #fff;
}

.btn-accent:hover {
    background: var(--accent-light);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #C0392B;
}

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

.btn-outline:hover {
    background: var(--bg);
    border-color: var(--text-light);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
}

.btn-icon {
    padding: 8px;
    border-radius: var(--radius-sm);
}

/* --- Forms --- */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--text);
    background: var(--bg-card);
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(41, 128, 185, 0.15);
}

.form-control::placeholder {
    color: var(--text-light);
}

select.form-control {
    cursor: pointer;
}

textarea.form-control {
    resize: vertical;
    min-height: 120px;
}

/* --- Alerts --- */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.alert-success { background: rgba(39, 174, 96, 0.1); border-left: 4px solid var(--accent); color: #1E8449; }
.alert-warning { background: rgba(243, 156, 18, 0.1); border-left: 4px solid var(--warning); color: #7D6608; }
.alert-danger  { background: rgba(231, 76, 60, 0.1); border-left: 4px solid var(--danger); color: #922B21; }
.alert-info    { background: rgba(41, 128, 185, 0.1); border-left: 4px solid var(--primary-light); color: #1B5E7B; }

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    backdrop-filter: blur(2px);
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* --- Import Preview --- */
.import-preview {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-top: 16px;
    max-height: 400px;
    overflow-y: auto;
}

.import-preview table tbody td {
    font-size: 0.8rem;
    padding: 8px 12px;
}

.presence-low {
    color: var(--danger);
    font-weight: 600;
}

.presence-warning {
    color: var(--warning);
    font-weight: 600;
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-light);
}

.empty-state i {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.4;
}

.empty-state p {
    font-size: 0.95rem;
    margin-bottom: 16px;
}

/* --- Login Page --- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
}

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    padding: 40px;
}

.login-card .login-brand {
    text-align: center;
    margin-bottom: 32px;
}

.login-card .login-brand h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 4px;
}

.login-card .login-brand p {
    font-size: 0.85rem;
    color: var(--text-light);
}

.login-card .btn-primary {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 0.95rem;
}

/* --- Utilities --- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-light); }
.text-danger { color: var(--danger); }
.text-success { color: var(--accent); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.w-100 { width: 100%; }
.hidden { display: none; }

.profile-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.profile-user-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}

.profile-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 700;
}

.profile-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}

.profile-email {
    font-size: 0.86rem;
    color: var(--text-light);
}

.profile-info-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.profile-info-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    background: var(--bg);
}

.profile-label {
    font-size: 0.82rem;
    color: var(--text-light);
    font-weight: 600;
}

.turmas-grupos {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.turma-grupo {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #fff;
}

.turma-header {
    background: var(--bg);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.turma-info {
    flex: 1;
}

.turma-info h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin: 0 0 4px 0;
}

.turma-meta {
    display: flex;
    gap: 8px;
    font-size: 0.8rem;
}

.turma-periodo,
.turma-ano {
    color: var(--text-light);
}

.turma-count {
    margin-left: 12px;
}

.ucs-lista {
    overflow: hidden;
}

.table-compact tbody td {
    padding: 10px 12px;
    font-size: 0.85rem;
}

@media (max-width: 991px) {
    .btn-sidebar-toggle {
        display: none;
    }

    .btn-mobile-menu {
        display: inline-flex;
    }

    .sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }

    .app-layout.mobile-sidebar-open .sidebar {
        transform: translateX(0);
    }

    .app-layout.mobile-sidebar-open .sidebar-backdrop {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .main-content,
    .app-layout.sidebar-collapsed .main-content {
        margin-left: 0;
        max-width: 100vw;
    }

    .header {
        padding: 0 16px;
    }

    .header-title {
        font-size: 1rem;
    }

    .page-content {
        padding: 20px 14px;
    }

    .card-header {
        padding: 14px 16px;
        flex-wrap: wrap;
        gap: 10px;
    }

    .card-body {
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
        gap: 12px;
        margin-bottom: 20px;
    }

    .stat-card {
        padding: 14px;
        gap: 12px;
    }

    .stat-card .stat-value {
        font-size: 1.3rem;
    }

    .table-responsive .table {
        min-width: 620px;
    }

    .profile-grid {
        grid-template-columns: 1fr;
    }

    .user-menu-name {
        max-width: 120px;
    }
}

@media (max-width: 640px) {
    .btn {
        width: 100%;
        justify-content: center;
    }

    .header-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .header {
        min-height: var(--header-height);
        height: auto;
        padding-top: 10px;
        padding-bottom: 10px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .profile-grid {
        grid-template-columns: 1fr;
    }

    .user-menu-name {
        max-width: 120px;
    }
}
