﻿/* ==========================================================================
   LEARN MANAGEMENT SYSTEM - ISOLATED STYLES (v3.0)
   Prefix: .lm-* to avoid conflicts with SchoolManagement
   ========================================================================== */

:root {
    /* Scoped Variables for Learn Module */
    --lm-primary: #1b6ec2;
    --lm-primary-hover: #4497eb;
    --lm-primary-soft: #eef2ff;
    --lm-success: #10b981;
    --lm-success-soft: #d1fae5;
    --lm-warning: #f59e0b;
    --lm-warning-soft: #fef3c7;
    --lm-danger: #ef4444;
    --lm-danger-soft: #fee2e2;
    --lm-text-main: #111827;
    --lm-text-muted: #6b7280;
    --lm-bg-body: #f3f4f6;
    --lm-bg-white: #ffffff;
    --lm-border: #e5e7eb;
    --lm-radius: 8px;
    --lm-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    /* ================ TKB ============ */
    --tkb-primary: #1b6ec2;
    --tkb-primary-hover: #4497eb;
    --tkb-bg: #f3f4f6;
    --tkb-border: #e5e7eb;
    --tkb-text: #1f2937;
    --tkb-danger: #ef4444;
    --tkb-white: #ffffff;
}

/* --- LAYOUT --- */
.lm-page-container {
    padding: 24px;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background-color: var(--lm-bg-body);
    font-family: 'Inter', system-ui, sans-serif;
    color: var(--lm-text-main);
}

.lm-animate-fade-in {
    animation: lmFadeIn 0.3s ease-out;
}

@keyframes lmFadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- CARD SYSTEM --- */
.lm-card {
    background: var(--lm-bg-white);
    border-radius: var(--lm-radius);
    box-shadow: var(--lm-shadow);
    border: 1px solid var(--lm-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 20px;
}

.lm-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--lm-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    flex-wrap: wrap;
    gap: 12px;
}

.lm-card-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--lm-text-main);
}

    .lm-card-title .material-icons-round {
        font-size: 24px;
        color: var(--lm-primary);
    }

.lm-card-subtitle {
    font-size: 0.85rem;
    color: var(--lm-text-muted);
    font-weight: 400;
    margin-top: 2px;
}

/* --- TOOLBAR & FILTERS --- */
.lm-toolbar {
    padding: 16px 20px;
    background: #f9fafb;
    border-bottom: 1px solid var(--lm-border);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    align-items: end;
}

.lm-filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.lm-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--lm-text-muted);
    letter-spacing: 0.02em;
}

.lm-input, .lm-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--lm-border);
    border-radius: 6px;
    font-size: 0.9rem;
    height: 38px;
    transition: all 0.2s;
    background-color: #fff;
}

    .lm-input:focus, .lm-select:focus {
        border-color: var(--lm-primary);
        outline: none;
        box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    }

/* Input with Icon */
.lm-input-icon-wrapper {
    position: relative;
    width: 100%;
}

    .lm-input-icon-wrapper .material-icons-round {
        position: absolute;
        left: 10px;
        top: 50%;
        transform: translateY(-50%);
        color: #9ca3af;
        pointer-events: none;
        font-size: 18px;
    }

    .lm-input-icon-wrapper input {
        padding-left: 34px;
    }

/* --- DATA TABLE --- */
.lm-table-wrapper {
    width: 100%;
    overflow-x: auto;
    background: #fff;
}

.lm-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 1000px;
}

    .lm-table th {
        background-color: #005b9f;
        color: #ffffff;
        font-weight: 600;
        font-size: 0.8rem;
        text-transform: uppercase;
        padding: 12px 16px;
        text-align: left;
        border-bottom: 1px solid var(--lm-border);
        white-space: nowrap;
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .lm-table td {
        padding: 12px 16px;
        border-bottom: 1px solid var(--lm-border);
        vertical-align: middle;
        color: var(--lm-text-main);
        font-size: 0.9rem;
        background: #fff;
    }

    .lm-table tr:hover td {
        background-color: #f8fafc;
    }

/* Sticky Columns for Schedule */
.lm-sticky-col-first {
    position: sticky;
    left: 0;
    z-index: 20;
    border-right: 1px solid var(--lm-border);
    background-color: #fcfcfc !important;
}

.lm-sticky-header-corner {
    position: sticky;
    top: 0;
    left: 0;
    z-index: 30;
    background-color: #f9fafb !important;
    border-right: 1px solid var(--lm-border);
}

/* --- BUTTONS --- */
.lm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 16px;
    height: 38px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
}

.lm-btn-primary {
    background: var(--lm-primary);
    color: white;
}

    .lm-btn-primary:hover {
        background: var(--lm-primary-hover);
        transform: translateY(-1px);
    }

.lm-btn-white {
    background: white;
    border-color: var(--lm-border);
    color: var(--lm-text-main);
}

    .lm-btn-white:hover {
        background: #f9fafb;
        border-color: #d1d5db;
    }

.lm-btn-danger-soft {
    background: var(--lm-danger-soft);
    color: var(--lm-danger);
}

    .lm-btn-danger-soft:hover {
        background: #fee2e2;
    }

.lm-btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 6px;
    background: transparent;
    border: none;
    color: var(--lm-text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

    .lm-btn-icon:hover {
        background: #f3f4f6;
        color: var(--lm-primary);
    }

    .lm-btn-icon.delete:hover {
        color: var(--lm-danger);
        background: var(--lm-danger-soft);
    }

/* --- BADGES --- */
.lm-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid transparent;
}

.lm-badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.lm-badge-success {
    background: var(--lm-success-soft);
    color: #065f46;
    border-color: #a7f3d0;
}

    .lm-badge-success .lm-badge-dot {
        background: var(--lm-success);
    }

.lm-badge-primary {
    background: var(--lm-primary-soft);
    color: #3730a3;
    border-color: #c7d2fe;
}

.lm-badge-warning {
    background: var(--lm-warning-soft);
    color: #92400e;
    border-color: #fde68a;
}

.lm-badge-gray {
    background: #f3f4f6;
    color: #4b5563;
    border-color: #e5e7eb;
}

/* --- MODAL --- */
.lm-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 2000;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(2px);
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.lm-modal-dialog {
    width: 90%;
    max-width: 600px;
    margin: 20px;
}

.lm-modal-content {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
    overflow: hidden;
    animation: lmPopIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    max-height: 85vh;
}

@keyframes lmPopIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.lm-modal-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--lm-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.lm-modal-body {
    padding: 24px;
    overflow-y: auto;
}

.lm-modal-footer {
    padding: 16px 24px;
    background: #f9fafb;
    border-top: 1px solid var(--lm-border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Custom: Schedule Card */
.lm-tkb-card {
    border-left: 3px solid;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 8px;
    margin-bottom: 4px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

    .lm-tkb-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
        z-index: 2;
    }

/* Pagination */
.lm-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-top: 1px solid var(--lm-border);
}

.lm-page-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--lm-border);
    background: white;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--lm-text-muted);
}

    .lm-page-btn.active {
        background: var(--lm-primary);
        color: white;
        border-color: var(--lm-primary);
    }
/* ==========================================================================
   ADD-ON: CHECKBOX & LIVE INDICATOR (Restored)
   ========================================================================== */

/* 1. Checkbox chọn nhiều (Nằm góc trên phải) */
.lm-tkb-checkbox {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 16px;
    height: 16px;
    cursor: pointer;
    opacity: 0; /* Ẩn mặc định */
    transition: opacity 0.2s ease;
    z-index: 10;
    accent-color: var(--lm-primary);
}

    /* Hiện checkbox khi hover vào thẻ HOẶC khi đã được checked */
    .lm-tkb-card:hover .lm-tkb-checkbox,
    .lm-tkb-checkbox:checked {
        opacity: 1;
    }

/* 2. Chấm đỏ báo hiệu đang học (Live Indicator) */
.lm-live-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: var(--lm-danger);
    border-radius: 50%;
    margin-left: 8px;
    vertical-align: middle;
    box-shadow: 0 0 0 rgba(239, 68, 68, 0.4);
    animation: lmPulseRed 2s infinite;
}

@keyframes lmPulseRed {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}
/* =========================================
   MOBILE RESPONSIVE POLISH (Max-width: 640px)
   Add this at the very end of LearnManagement.css
   ========================================= */
@media (max-width: 640px) {
    .lm-page-container {
        padding: 12px;
    }

    /* Modal: Full màn hình trên mobile */
    .lm-modal-dialog {
        width: 100%;
        height: 100%;
        margin: 0;
        max-width: none;
    }

    .lm-modal-content {
        border-radius: 0;
        height: 100vh;
        max-height: 100vh;
    }

    /* Form trong Modal: 1 cột */
    .lm-modal-body > div {
        grid-template-columns: 1fr !important;
    }

    /* Header Schedule: Gọn lại */
    .lm-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

        .lm-card-header > div:last-child {
            width: 100%;
            overflow-x: auto; /* Cho phép cuộn nút nếu quá dài */
            justify-content: space-between;
        }

    /* Toolbar */
    .lm-toolbar {
        grid-template-columns: 1fr;
        padding: 12px;
    }

    /* Table Header Sticky: Giảm z-index để không che Modal */
    .lm-table th {
        z-index: 5;
    }
}
/* ==========================================================================
   ISOLATED STYLES: THỜI KHÓA BIỂU (Prefix: .lm-tkb-*)
   ========================================================================== */

/* --- 1. LAYOUT & CONTAINER --- */
.lm-tkb-page {
    padding: 24px;
    background-color: var(--tkb-bg);
    min-height: 80vh;
    font-family: 'Inter', system-ui, sans-serif;
    color: var(--tkb-text);
}

.lm-tkb-panel {
    background: var(--tkb-white);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid var(--tkb-border);
    display: flex;
    flex-direction: column;
    max-height: 76vh;
}

.lm-tkb-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--tkb-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.lm-tkb-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

    .lm-tkb-title .material-icons-round {
        color: var(--tkb-primary);
        font-size: 24px;
    }

/* --- 2. BUTTONS & INPUTS --- */
.lm-tkb-btn {
    padding: 0 16px;
    height: 38px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: 0.2s;
    white-space: nowrap;
}

    .lm-tkb-btn.primary {
        background: var(--tkb-primary);
        color: white;
    }

        .lm-tkb-btn.primary:hover {
            background: var(--tkb-primary-hover);
        }

    .lm-tkb-btn.white {
        background: white;
        border-color: var(--tkb-border);
        color: var(--tkb-text);
    }

        .lm-tkb-btn.white:hover {
            background: #f9fafb;
        }

    .lm-tkb-btn.danger {
        background: var(--tkb-danger);
        color: white;
    }

.lm-tkb-input, .lm-tkb-select {
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--tkb-border);
    border-radius: 6px;
    width: 100%;
    outline: none;
    font-size: 0.9rem;
}

    .lm-tkb-input:focus {
        border-color: var(--tkb-primary);
        box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    }

/* --- 3. CUSTOM SEARCH SELECT (Isolated) --- */
.lm-tkb-search-box {
    position: relative;
    width: 100%;
}

    .lm-tkb-search-box input {
        width: 100%;
        cursor: text;
    }

.lm-tkb-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-height: 200px;
    overflow-y: auto;
    background: white;
    border: 1px solid var(--tkb-border);
    border-radius: 6px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    z-index: 100; /* Cao hơn modal */
    margin-top: 4px;
    padding: 4px;
}

.lm-tkb-dropdown-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.9rem;
    border-radius: 4px;
    color: var(--tkb-text);
}

    .lm-tkb-dropdown-item:hover {
        background-color: #f3f4f6;
        color: var(--tkb-primary);
    }

.lm-tkb-dropdown-no-result {
    padding: 12px;
    text-align: center;
    color: #6b7280;
    font-size: 0.85rem;
}

/* --- 4. TABLE --- */
.lm-tkb-table-wrapper {
    overflow-x: auto;
    width: 100%;
}

.lm-tkb-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 900px;
}

    .lm-tkb-table th {
        background: #005b9f;
        color: #ffffff;
        padding: 12px;
        text-align: center;
        font-weight: 600;
        font-size: 0.8rem;
        border-bottom: 1px solid var(--tkb-border);
        position: sticky;
        top: 0;
        z-index: 20;
    }

    .lm-tkb-table td {
        border-bottom: 1px solid var(--tkb-border);
        border-right: 1px dashed var(--tkb-border);
        padding: 6px;
        vertical-align: top;
        height: 100px;
    }
        /* Cột tiết (Sticky Left) */
        .lm-tkb-table td:first-child {
            border-right: 2px solid var(--tkb-border);
            background: #fcfcfc;
            width: 60px;
            text-align: center;
            vertical-align: middle;
            font-weight: bold;
            position: sticky;
            left: 0;
            z-index: 10;
        }

/* --- 5. TKB ITEM CARD (Cục tiết học) --- */
.lm-tkb-item {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 8px;
    margin-bottom: 4px;
    cursor: pointer;
    border-left: 4px solid var(--tkb-primary); /* Default color */
    transition: 0.2s;
    position: relative;
}

    .lm-tkb-item:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 6px rgba(0,0,0,0.05);
        z-index: 5;
    }

    .lm-tkb-item.active {
        border-color: var(--tkb-danger);
        background: #fef2f2;
    }

    .lm-tkb-item b {
        display: block;
        font-size: 0.9rem;
        margin-bottom: 2px;
    }

    .lm-tkb-item div {
        font-size: 0.8rem;
        color: #4b5563;
    }

    .lm-tkb-item small {
        font-size: 0.75rem;
        color: #9ca3af;
    }

.lm-tkb-live-dot {
    display: inline-block;
    background: var(--tkb-danger);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    margin-bottom: 4px;
    animation: tkbPulse 1.5s infinite;
}

@keyframes tkbPulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }

    100% {
        opacity: 1;
    }
}

/* --- 6. MODAL --- */
.lm-tkb-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lm-tkb-modal-content {
    background: #fff;
    width: 550px;
    max-width: 95%;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 25px rgba(0,0,0,0.1);
    max-height: 90vh;
    overflow: visible !important; /* Để dropdown tràn ra ngoài */
}

.lm-tkb-modal-body {
    padding: 24px;
    overflow-y: auto;
    overflow-x: visible;
}

.lm-tkb-modal-footer {
    padding: 16px 24px;
    background: #f9fafb;
    border-top: 1px solid var(--tkb-border);
    border-radius: 0 0 12px 12px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* --- 7. TABS & HELPERS --- */
.lm-tkb-tabs {
    display: flex;
    border-bottom: 1px solid var(--tkb-border);
    margin-bottom: 20px;
}

.lm-tkb-tab {
    padding: 10px 16px;
    cursor: pointer;
    color: #6b7280;
    border-bottom: 2px solid transparent;
    font-weight: 600;
    font-size: 0.9rem;
}

    .lm-tkb-tab.active {
        color: var(--tkb-primary);
        border-bottom-color: var(--tkb-primary);
    }

.lm-tkb-day-wrap {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.lm-tkb-day-box {
    width: 36px;
    height: 36px;
    border: 1px solid var(--tkb-border);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    color: #6b7280;
    transition: 0.15s;
    background: #fff;
}

    .lm-tkb-day-box.selected {
        background: var(--tkb-primary);
        color: white;
        border-color: var(--tkb-primary);
    }

.lm-tkb-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.lm-tkb-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: #374151;
}
/* --- TOOLBAR BỘ LỌC --- */
.lm-tkb-toolbar {
    display: flex;
    gap: 15px;
    align-items: center;
    padding: 12px 20px;
    background-color: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.lm-tkb-filter-group {
    width: 250px;
    position: relative;
}

.lm-tkb-clear-icon {
    position: absolute;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 16px;
    color: #ef4444;
    z-index: 10;
    transition: color 0.2s;
}

    .lm-tkb-clear-icon:hover {
        color: #dc2626;
    }

.lm-tkb-dropdown-item.is-all {
    font-weight: 700;
    color: #4f46e5;
    border-bottom: 1px dashed #e5e7eb;
}

.lm-tkb-result-count {
    margin-left: auto;
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    color: #6b7280;
    font-weight: 500;
}
/* MOBILE */
@media (max-width: 576px) {

    .lm-page-container {
        padding: 15px;
    }

    .lm-card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .lm-toolbar {
        grid-template-columns: 1fr;
    }

    .lm-table {
        min-width: 700px;
    }
}

/* TABLET */
@media (max-width: 992px) {

    .lm-toolbar {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {

    .lm-tkb-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

        .lm-tkb-header > div:last-child {
            width: 100%;
            flex-wrap: wrap;
        }

    .lm-tkb-btn {
        flex: 1 1 48%;
        justify-content: center;
    }
}

@media (max-width: 768px) {

    .lm-tkb-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .lm-tkb-filter-group {
        width: 100%;
    }

    .lm-tkb-result-count {
        margin-left: 0;
        justify-content: flex-start;
    }
}

.lm-tkb-table-wrapper {
    overflow-x: auto;
    width: 100%;
}

@media (max-width: 768px) {

    .lm-tkb-table {
        min-width: 700px;
    }
}

.lm-tkb-item {
    position: relative;
    padding-right: 26px;
}

    .lm-tkb-item input[type="checkbox"] {
        position: absolute;
        right: 6px;
        top: 6px;
    }

@media (max-width: 768px) {

    .lm-tkb-modal-content {
        width: 95%;
        max-height: 90vh;
        overflow-y: auto;
    }

    .lm-tkb-grid-2 {
        grid-template-columns: 1fr !important;
    }

    .lm-tkb-controlday {
        display: none;
    }
}
