:root {
    --primary: #0d6efd;
    --primary-hover: #0b5ed7;
    --primary-light: rgba(13, 110, 253, 0.1);
    --sidebar-width: 260px;
    --chat-sidebar-width: 320px;
    --success: #198754;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #0dcaf0;
    --light: #f8f9fa;
    --dark: #212529;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-500: #6c757d;
    --gray-700: #495057;
    --gray-900: #212529;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-pill: 20px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f8f9fa;
    color: #212529;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: linear-gradient(180deg, #1a1d29 0%, #2d3142 100%);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header .logo {
    color: #fff;
    font-size: 1.25rem;
    font-weight: 700;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-header .logo i {
    color: var(--primary);
    font-size: 1.5rem;
}

.sidebar-nav {
    padding: 16px 12px;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    margin-bottom: 4px;
    font-size: 0.9rem;
}

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

.sidebar-nav .nav-link.active {
    background: var(--primary);
    color: #fff;
    font-weight: 500;
}

.sidebar-nav .nav-link i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.sidebar-nav .nav-section {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 16px 16px 8px;
    font-weight: 600;
}

/* ==================== CARDS ==================== */
.card {
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    padding: 16px 20px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

/* ==================== STAT CARDS ==================== */
.stat-card {
    background: #fff;
    border-radius: var(--radius);
    border-left: 4px solid var(--primary);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

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

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--gray-900);
}

.stat-label {
    color: var(--gray-500);
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ==================== COURSE CARDS ==================== */
.course-card {
    border: none;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.course-card .course-img {
    height: 160px;
    object-fit: cover;
    width: 100%;
}

.course-card .card-body {
    padding: 16px;
}

.course-card .card-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 8px;
}

.course-card .card-text {
    color: var(--gray-500);
    font-size: 0.85rem;
}

/* ==================== BUTTONS ==================== */
.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
    border-radius: var(--radius-sm);
    font-weight: 500;
    padding: 10px 20px;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.35);
}

.btn-outline-primary {
    border-radius: var(--radius-sm);
    font-weight: 500;
}

/* ==================== FORMS ==================== */
.form-control,
.form-select {
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-300);
    padding: 10px 14px;
    font-size: 0.9rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-label {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--gray-700);
    margin-bottom: 6px;
}

/* ==================== TABLES ==================== */
.table {
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 0;
}

.table thead th {
    background-color: var(--gray-100);
    border: none;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    color: var(--gray-500);
    padding: 12px 16px;
}

.table tbody td {
    padding: 14px 16px;
    vertical-align: middle;
    border-color: var(--gray-200);
}

.table tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.03);
}

/* ==================== PROGRESS ==================== */
.progress {
    border-radius: var(--radius-pill);
    height: 8px;
    background-color: var(--gray-200);
    overflow: hidden;
}

.progress-bar {
    border-radius: var(--radius-pill);
    background: linear-gradient(90deg, var(--primary), #6ea8fe);
    transition: width 0.4s ease;
}

/* ==================== LECCIONES ==================== */
.leccion-item {
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 12px;
    transition: all 0.2s ease;
    background: #fff;
}

.leccion-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
    transform: translateX(4px);
}

.leccion-item.completada {
    border-color: var(--success);
    background: rgba(25, 135, 84, 0.04);
}

.leccion-item .leccion-number {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-200);
    color: var(--gray-700);
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.leccion-item.completada .leccion-number {
    background: var(--success);
    color: #fff;
}

/* ==================== FORO ==================== */
.foro-hilo {
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 16px;
    background: #fff;
    transition: all 0.2s ease;
}

.foro-hilo:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.foro-hilo .hilo-titulo {
    font-weight: 600;
    color: var(--gray-900);
    text-decoration: none;
    font-size: 1.05rem;
}

.foro-hilo .hilo-titulo:hover {
    color: var(--primary);
}

/* ==================== MODALS ==================== */
.modal-content {
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

.modal-header {
    border-bottom: 1px solid var(--gray-200);
    padding: 20px 24px;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    border-top: 1px solid var(--gray-200);
    padding: 16px 24px;
}

/* ==================== ALERTS ==================== */
.alert {
    border-radius: var(--radius-sm);
    border: none;
    font-size: 0.9rem;
}

/* ==================== BADGES ==================== */
.badge {
    font-weight: 500;
    font-size: 0.7rem;
    letter-spacing: 0.3px;
    padding: 5px 10px;
    border-radius: 6px;
}

/* ==================== CHAT ==================== */
.chat-container {
    display: flex;
    height: 100vh;
    background: #fff;
}

.chat-sidebar {
    width: var(--chat-sidebar-width);
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    background: #fff;
    flex-shrink: 0;
}

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

.chat-search {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-200);
}

.contacts-list {
    flex-grow: 1;
    overflow-y: auto;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    cursor: pointer;
    transition: background 0.2s ease;
    border-bottom: 1px solid var(--gray-100);
}

.contact-item:hover {
    background: var(--gray-100);
}

.contact-item.active {
    background: var(--primary-light);
    border-left: 3px solid var(--primary);
}

.contact-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #6ea8fe);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
    flex-shrink: 0;
    position: relative;
}

.contact-info {
    flex-grow: 1;
    min-width: 0;
}

.contact-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.contact-preview {
    color: var(--gray-500);
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-meta {
    text-align: right;
    flex-shrink: 0;
}

.contact-time {
    color: var(--gray-500);
    font-size: 0.7rem;
}

/* ==================== CHAT MAIN ==================== */
.chat-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--gray-200);
    background: #fff;
}

.chat-contact-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--gray-100);
}

.chat-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
}

/* ==================== CHAT BUBBLES ==================== */
.chat-bubble {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    font-size: 0.9rem;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
}

.chat-bubble.sent {
    background: var(--primary);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chat-bubble.received {
    background: #fff;
    color: var(--gray-900);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.chat-bubble .bubble-time {
    font-size: 0.65rem;
    opacity: 0.7;
    margin-top: 4px;
    text-align: right;
}

.chat-bubble.received .bubble-time {
    color: var(--gray-500);
}

.chat-bubble .bubble-sender {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 4px;
}

/* ==================== CHAT INPUT ==================== */
.chat-input-container {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
    background: #fff;
}

.chat-input-form {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-input-field {
    flex-grow: 1;
    border-radius: var(--radius-pill) !important;
    padding: 12px 20px !important;
    border: 1px solid var(--gray-300) !important;
    font-size: 0.9rem;
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50% !important;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
}

.chat-attach-btn {
    color: var(--gray-500);
    padding: 8px;
    border-radius: 50%;
    transition: color 0.2s ease;
}

.chat-attach-btn:hover {
    color: var(--primary);
}

/* ==================== ONLINE INDICATOR ==================== */
.online-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    border: 2px solid #fff;
    position: absolute;
    bottom: 2px;
    right: 2px;
}

/* ==================== UNREAD BADGE ==================== */
.badge-unread {
    background: var(--danger);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

/* ==================== PAGE HEADER ==================== */
.page-header {
    margin-bottom: 32px;
}

.page-header h2 {
    font-weight: 700;
    margin-bottom: 4px;
}

/* ==================== EMPTY STATES ==================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state i {
    font-size: 3rem;
    color: var(--gray-300);
    margin-bottom: 16px;
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}

/* ==================== ANIMATIONS ==================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.slide-in {
    animation: slideIn 0.2s ease;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        transform: translateX(-100%);
        z-index: 1050;
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1040;
    }

    .sidebar-overlay.show {
        display: block;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .chat-sidebar {
        position: fixed;
        width: 100%;
        z-index: 1050;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .chat-sidebar.show {
        transform: translateX(0);
    }

    .chat-bubble {
        max-width: 85%;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-value {
        font-size: 1.4rem;
    }

    .stat-icon {
        width: 44px;
        height: 44px;
        font-size: 1.2rem;
    }
}

@media (max-width: 576px) {
    .page-header h2 {
        font-size: 1.25rem;
    }

    .card-body {
        padding: 16px;
    }

    .leccion-item {
        padding: 12px 16px;
    }
}
