/* ==========================================================================
   EduTech — SaaS Gestão Escolar Design System
   Modern Glassmorphic UI with CSS Variables & Responsive Tokens
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');
@import url('https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css');

:root {
    /* Brand & Dynamic Colors */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: rgba(37, 99, 235, 0.1);
    --secondary: #0f172a;
    --accent: #8b5cf6;
    
    /* Neutrals & Surfaces */
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;
    --bg-sidebar-hover: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    
    /* Text */
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    
    /* Borders & Lines */
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    
    /* Status Colors */
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #06b6d4;
    --info-light: #cffafe;
    
    /* Shadows & Glass */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Theme Support */
[data-theme="dark"] {
    --bg-main: #0b0f19;
    --bg-card: #131b2e;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #1e293b;
    --border-light: #182235;
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

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

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    font-size: 0.95rem;
    -webkit-font-smoothing: antialiased;
}

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

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

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

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    z-index: 998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

body.sidebar-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
}

.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 999;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-x: hidden;
    overflow-y: auto;
}

.sidebar-header {
    padding: 1.25rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    min-height: 70px;
}

.sidebar-brand-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar-logo {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 1.25rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.sidebar-brand-info {
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.sidebar-brand-name {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.sidebar-brand-subtitle {
    font-size: 0.72rem;
    color: #64748b;
}

.sidebar-collapse-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.85rem;
    padding: 0;
}

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

.sidebar-menu {
    padding: 1.25rem 0.75rem;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1;
    overflow-x: hidden;
}

.sidebar-menu-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    padding: 0.75rem 0.75rem 0.25rem;
    white-space: nowrap;
    transition: opacity 0.2s ease;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    color: var(--sidebar-text);
    font-weight: 500;
    font-size: 0.92rem;
    transition: var(--transition);
    white-space: nowrap;
    position: relative;
}

.sidebar-link i {
    font-size: 1.2rem;
    min-width: 1.25rem;
    text-align: center;
}

.sidebar-link span {
    transition: opacity 0.2s ease;
}

.sidebar-link:hover {
    background-color: var(--bg-sidebar-hover);
    color: #fff;
}

.sidebar-link.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 55px;
    overflow: hidden;
    white-space: nowrap;
}

/* ==========================================================================
   Collapsed Desktop Sidebar State
   ========================================================================== */
@media (min-width: 993px) {
    html.sidebar-collapsed .sidebar,
    body.sidebar-collapsed .sidebar {
        width: 76px;
    }

    html.sidebar-collapsed .sidebar-header,
    body.sidebar-collapsed .sidebar-header {
        justify-content: center;
        padding: 1rem 0.5rem;
    }

    html.sidebar-collapsed .sidebar-brand-info,
    body.sidebar-collapsed .sidebar-brand-info,
    html.sidebar-collapsed .sidebar-link span,
    body.sidebar-collapsed .sidebar-link span,
    html.sidebar-collapsed .sidebar-footer span,
    body.sidebar-collapsed .sidebar-footer span {
        opacity: 0;
        pointer-events: none;
        display: none;
    }

    html.sidebar-collapsed .sidebar-collapse-btn,
    body.sidebar-collapsed .sidebar-collapse-btn {
        display: none;
    }

    html.sidebar-collapsed .sidebar-menu-title,
    body.sidebar-collapsed .sidebar-menu-title {
        opacity: 0;
        height: 0;
        padding: 0;
        margin: 0.35rem 0;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        overflow: hidden;
    }

    html.sidebar-collapsed .sidebar-menu,
    body.sidebar-collapsed .sidebar-menu {
        padding: 1rem 0.5rem;
        align-items: center;
    }

    html.sidebar-collapsed .sidebar-link,
    body.sidebar-collapsed .sidebar-link {
        justify-content: center;
        padding: 0.75rem;
        width: 48px;
        height: 48px;
        margin: 0 auto;
        gap: 0;
    }

    html.sidebar-collapsed .sidebar-link i,
    body.sidebar-collapsed .sidebar-link i {
        font-size: 1.35rem;
        margin: 0;
    }

    html.sidebar-collapsed .sidebar-footer,
    body.sidebar-collapsed .sidebar-footer {
        justify-content: center;
        padding: 1rem 0.5rem;
    }

    html.sidebar-collapsed .main-wrapper,
    body.sidebar-collapsed .main-wrapper {
        margin-left: 76px;
    }

    /* Floating Tooltips in Collapsed Mode */
    html.sidebar-collapsed .sidebar-link[data-tooltip]::after,
    body.sidebar-collapsed .sidebar-link[data-tooltip]::after {
        content: attr(data-tooltip);
        position: absolute;
        left: calc(100% + 12px);
        top: 50%;
        transform: translateY(-50%) scale(0.95);
        background: #1e293b;
        color: #fff;
        padding: 0.4rem 0.8rem;
        border-radius: var(--radius-sm);
        font-size: 0.82rem;
        font-weight: 500;
        white-space: nowrap;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.15s ease, transform 0.15s ease;
        box-shadow: var(--shadow-lg);
        border: 1px solid rgba(255, 255, 255, 0.1);
        z-index: 1000;
    }

    html.sidebar-collapsed .sidebar-link[data-tooltip]:hover::after,
    body.sidebar-collapsed .sidebar-link[data-tooltip]:hover::after {
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }
}

/* Main Content Area */
.main-wrapper {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
}

/* Top Navbar */
.top-navbar {
    height: 70px;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 90;
    backdrop-filter: blur(8px);
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.sidebar-toggle-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.25rem;
    transition: var(--transition);
}

.sidebar-toggle-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.school-badge {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: var(--primary-light);
    color: var(--primary);
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.85rem;
}

.user-profile-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    position: relative;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--text-main);
    overflow: hidden;
    border: 2px solid var(--border-color);
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Banner de Impersonate */
.impersonate-banner {
    background: linear-gradient(90deg, #f59e0b, #d97706);
    color: #fff;
    padding: 0.6rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.88rem;
    font-weight: 600;
}

.impersonate-banner a {
    background: rgba(0, 0, 0, 0.2);
    color: #fff;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
}

/* Content Container */
.content-body {
    padding: 2rem;
    flex: 1;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

.page-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

/* Cards & Grid System */
.grid-4 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
    border-color: #cbd5e1;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Stat Cards */
.stat-card {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    flex-shrink: 0;
}

.stat-icon.primary { background: var(--primary-light); color: var(--primary); }
.stat-icon.success { background: var(--success-light); color: var(--success); }
.stat-icon.warning { background: var(--warning-light); color: var(--warning); }
.stat-icon.info { background: var(--info-light); color: var(--info); }
.stat-icon.accent { background: rgba(139, 92, 246, 0.1); color: var(--accent); }

.stat-val {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.1;
}

.stat-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    font-size: 0.92rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary);
    color: #fff;
}
.btn-primary:hover {
    background-color: var(--primary-hover);
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-outline {
    background-color: transparent;
    border-color: var(--border-color);
    color: var(--text-main);
}
.btn-outline:hover {
    background-color: var(--border-light);
    border-color: #cbd5e1;
}

.btn-success { background-color: var(--success); color: #fff; }
.btn-success:hover { background-color: #059669; color: #fff; }

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

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.82rem;
    border-radius: var(--radius-sm);
}

/* Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.92rem;
}

.table th {
    background: var(--bg-main);
    color: var(--text-muted);
    font-weight: 600;
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    vertical-align: middle;
}

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

.table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.015);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    font-weight: 600;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: #b45309; }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--info-light); color: #0e7490; }
.badge-neutral { background: var(--border-color); color: var(--text-muted); }

/* Form Controls */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.4rem;
}

.form-control, .form-select {
    width: 100%;
    padding: 0.65rem 0.95rem;
    font-size: 0.92rem;
    font-family: inherit;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-card);
    color: var(--text-main);
    transition: var(--transition);
}

.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon-btn {
    position: absolute;
    right: 0.75rem;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
}

/* Flash Alerts */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    font-size: 0.92rem;
}

.alert-success { background: var(--success-light); color: #065f46; border: 1px solid #a7f3d0; }
.alert-error, .alert-danger { background: var(--danger-light); color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: var(--info-light); color: #155e75; border: 1px solid #a5f3fc; }

/* Auth Pages Full Screen Card */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: radial-gradient(circle at 10% 20%, rgba(37, 99, 235, 0.08) 0%, rgba(248, 250, 252, 1) 90%);
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: 2.5rem;
}

.auth-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 2rem;
    text-align: center;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1.5rem;
}

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

.modal-box {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 540px;
    border: 1px solid var(--border-color);
    animation: modalPop 0.2s ease-out;
}

@keyframes modalPop {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Mobile Responsiveness */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        width: 270px !important;
        box-shadow: none;
    }
    
    body.sidebar-open .sidebar,
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.4);
    }
    
    .main-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    .sidebar-collapse-btn {
        display: flex;
    }
    
    .top-navbar {
        padding: 0 1rem;
    }
    
    .school-badge span {
        max-width: 140px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .content-body {
        padding: 1rem;
    }
}

@media (max-width: 576px) {
    .school-badge {
        display: none;
    }
    
    .user-profile-menu span {
        display: none;
    }
}

/* Print Friendly Styles for Boletim */
@media print {
    .sidebar, .top-navbar, .btn, .impersonate-banner, .page-header-actions {
        display: none !important;
    }
    .main-wrapper {
        margin-left: 0 !important;
    }
    body {
        background: #fff !important;
        color: #000 !important;
    }
    .card {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
    }
}
