@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-color: #f3f4f6;
    --sidebar-bg: #ffffff;
    --card-bg: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    --primary: #6c5ce7;
    --primary-gradient: linear-gradient(135deg, #6c5ce7, #a29bfe);
    --secondary-gradient: linear-gradient(135deg, #00b894, #55efc4);
    --border-color: rgba(0, 0, 0, 0.06);
    --hover-bg: #f9fafb;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    --card-shadow: 0 10px 30px rgba(108, 92, 231, 0.04);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg-color: #0b0f19;
    --sidebar-bg: #111827;
    --card-bg: #1f2937;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-muted: #6b7280;
    --border-color: rgba(255, 255, 255, 0.06);
    --hover-bg: #374151;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
    transition: var(--transition);
    min-height: 100vh;
    overflow-x: hidden;
}

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

/* Sidebar General */
.sidebar {
    width: 280px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px;
    transition: var(--transition);
    z-index: 1000;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 32px;
    text-decoration: none;
}

.sidebar-logo i {
    font-size: 1.5rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 12px;
    font-weight: 500;
    transition: var(--transition);
}

.sidebar-link:hover {
    color: var(--primary);
    background-color: var(--hover-bg);
    transform: translateX(4px);
}

.sidebar-link.active {
    color: white;
    background: var(--primary-gradient);
    box-shadow: 0 4px 12px rgba(108, 92, 231, 0.3);
}

/* Contenido del Dashboard */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 32px;
}

/* Header superior */
.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    gap: 16px;
}

.search-bar {
    position: relative;
    max-width: 320px;
    width: 100%;
}

.search-bar input {
    width: 100%;
    padding: 12px 16px 12px 42px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background-color: var(--card-bg);
    color: var(--text-primary);
    outline: none;
    transition: var(--transition);
}

.search-bar input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}

.search-bar i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

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

.theme-toggle,
.btn-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background-color: var(--card-bg);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.theme-toggle:hover,
.btn-icon:hover {
    background-color: var(--hover-bg);
    border-color: var(--primary);
}

.profile-widget {
    display: flex;
    align-items: center;
    gap: 12px;
}

.profile-avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--primary-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* Jumbotron Modernizado */
.welcome-banner {
    background: var(--primary-gradient);
    border-radius: 24px;
    padding: 40px;
    color: white;
    position: relative;
    overflow: hidden;
    margin-bottom: 32px;
    box-shadow: 0 10px 30px rgba(108, 92, 231, 0.2);
}

.welcome-banner::before {
    content: '';
    position: absolute;
    top: -50px;
    right: -50px;
    width: 250px;
    height: 250px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
}

/* Stats Cards */
.stat-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 24px;
    box-shadow: var(--shadow);
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--card-shadow);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.primary {
    background-color: rgba(108, 92, 231, 0.1);
    color: var(--primary);
}

.stat-icon.success {
    background-color: rgba(0, 184, 148, 0.1);
    color: #00b894;
}

.stat-number {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

/* Subject Grid */
.subject-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

.subject-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
    transition: var(--transition);
    height: 100%;
}

.subject-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--card-shadow);
    border-color: rgba(108, 92, 231, 0.3);
}

.subject-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.subject-badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.subject-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.subject-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.subject-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 24px;
    flex-grow: 1;
    line-height: 1.5;
}

.subject-progress-container {
    margin-bottom: 20px;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.progress-bar-bg {
    height: 8px;
    background-color: var(--hover-bg);
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.5s ease-in-out;
}

.subject-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
}

.subject-link {
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.subject-link:hover {
    color: #4834d4;
    transform: translateX(4px);
}

/* Layout con Sidebar de Materias (dos columnas en página de materia) */
.subject-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 32px;
    align-items: start;
}

.subject-sidebar {
    background-color: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 24px;
    box-shadow: var(--shadow);
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    position: sticky;
    top: 32px;
}

/* Layout con Menú Flotante de Clases (solo visible dentro de una clase) */
.class-floating-sidebar {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 320px;
    height: 75vh;
    background-color: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    pointer-events: none;
}

.class-floating-sidebar.show,
.class-floating-sidebar.active {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

.class-floating-sidebar-content {
    flex-grow: 1;
    overflow-y: auto;
}

.class-fab-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1060;
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 6px 20px rgba(108, 92, 231, 0.4);
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}

.class-fab-btn:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 8px 24px rgba(108, 92, 231, 0.5);
    color: white;
}

.sidebar-floating-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.class-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.class-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 16px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
}

.class-item:hover {
    background-color: var(--hover-bg);
    color: var(--text-primary);
}

.class-item.active {
    background-color: var(--hover-bg);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}

.class-checkbox {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 2px solid var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.class-checkbox.checked {
    background-color: #00b894;
    border-color: #00b894;
    color: white;
}

.class-checkbox i {
    font-size: 0.75rem;
}

.class-item-text {
    flex-grow: 1;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Área de contenido de clase */
.class-content-wrapper {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 40px;
    box-shadow: var(--shadow);
}

.class-detail-section {
    display: none;
}

.class-detail-section.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

/* Objetivos */
.card-objetivos {
    border: 1px solid var(--border-color);
    border-radius: 16px;
    background: var(--hover-bg);
    padding: 20px;
    height: 100%;
}

.badge-clase {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.btn-primary-gradient {
    background: var(--primary-gradient);
    border: none;
    color: white;
    border-radius: 12px;
    padding: 10px 24px;
    font-weight: 500;
    transition: var(--transition);
    box-shadow: 0 4px 12px rgba(108, 92, 231, 0.2);
}

.btn-primary-gradient:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(108, 92, 231, 0.35);
    color: white;
}

/* Responsive */

/* Acceso por PIN de materias */
.teacher-pin-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--primary);
    background: rgba(108, 92, 231, 0.1);
    border: 1px solid rgba(108, 92, 231, 0.2);
    border-radius: 12px;
    font-weight: 600;
}

.teacher-pin-button:hover {
    color: white;
    background: var(--primary);
}

.access-modal-content {
    color: var(--text-primary);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    box-shadow: var(--shadow);
}

.access-modal-content .btn-close {
    filter: var(--bs-btn-close-white-filter, none);
}

[data-theme="dark"] .access-modal-content .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

.access-modal-content .form-control,
.access-modal-content .form-select {
    color: var(--text-primary);
    background-color: var(--bg-color);
    border-color: var(--border-color);
}

.access-modal-content .form-control:focus,
.access-modal-content .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(108, 92, 231, 0.18);
}

.access-modal-icon {
    display: inline-flex;
    width: 48px;
    height: 48px;
    align-items: center;
    justify-content: center;
    color: white;
    background: var(--primary-gradient);
    border-radius: 14px;
    font-size: 1.25rem;
}

.access-pin-input {
    font-size: 1.4rem;
    letter-spacing: 0.45rem;
    text-align: center;
}

.teacher-session-bar {
    padding: 10px 12px;
    background: var(--hover-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 16px;
    }

    .sidebar-logo {
        margin-bottom: 16px;
    }

    .sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
    }

    .sidebar-link {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .main-content {
        padding: 20px;
    }

    .header-top {
        flex-direction: column;
        align-items: stretch;
    }

    .search-bar {
        max-width: none;
    }
}

/* Animaciones */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}
