/* ==========================================================================
   css/style.css - Hệ Thống Xếp Lịch & Quản Lý Tuần Khóa Học
   ========================================================================== */

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #16a34a;
    --success-hover: #15803d;
    --info: #0891b2;
    --info-hover: #0e7490;
    --purple: #7c3aed;
    --purple-hover: #6d28d9;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --border: #cbd5e1;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --warning: #f59e0b;
    --text: #1e293b;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg);
    color: var(--text);
    padding: 20px;
}

.container {
    max-width: 1350px;
    margin: 0 auto;
}

header {
    margin-bottom: 24px;
    position: relative;
    text-align: center;
}

.lang-switch-box {
    position: absolute;
    right: 0;
    top: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.lang-select-btn {
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: white;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
}

.btn-lang-import {
    padding: 6px 10px;
    background: #e2e8f0;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.btn-lang-import:hover {
    background: #cbd5e1;
}

h1 {
    color: var(--primary);
    margin-bottom: 8px;
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.tab-btn {
    padding: 10px 20px;
    border: none;
    background: #e2e8f0;
    color: #475569;
    border-radius: 6px 6px 0 0;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--card-bg);
    color: var(--primary);
    border-top: 3px solid var(--primary);
}

.config-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 0 8px 8px 8px;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    margin-bottom: 20px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 15px;
}

label {
    font-weight: 600;
    font-size: 0.95rem;
}

textarea, input[type="date"], select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    outline: none;
    font-family: inherit;
}

textarea {
    height: 95px;
    resize: vertical;
}

textarea:focus, input[type="date"]:focus, select:focus {
    border-color: var(--primary);
}

.helper-text {
    font-size: 0.82rem;
    color: #64748b;
    line-height: 1.4;
}

.class-dates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    background: #f8fafc;
    padding: 14px;
    border-radius: 6px;
    border: 1px solid var(--border);
    margin-top: 5px;
    max-height: 220px;
    overflow-y: auto;
}

.class-date-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: white;
    padding: 8px 12px;
    border-radius: 5px;
    border: 1px solid #e2e8f0;
}

.class-date-item input[type="date"] {
    padding: 5px 8px;
    font-size: 0.9rem;
}

.week-bar {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 14px 20px;
    margin-bottom: 22px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.week-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.week-info-badge {
    background: var(--primary);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.95rem;
}

.week-dates {
    font-size: 0.95rem;
    color: #1e3a8a;
    font-weight: 600;
}

.action-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 10px;
}

.btn {
    padding: 10px 18px;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
}

.btn:active { transform: scale(0.98); }
.btn-primary { background-color: var(--primary); }
.btn-primary:hover { background-color: var(--primary-hover); }
.btn-success { background-color: var(--success); }
.btn-success:hover { background-color: var(--success-hover); }
.btn-info { background-color: var(--info); }
.btn-info:hover { background-color: var(--info-hover); }
.btn-purple { background-color: var(--purple); }
.btn-purple:hover { background-color: var(--purple-hover); }

.btn-nav {
    background-color: white;
    color: var(--primary);
    border: 1px solid var(--primary);
    padding: 6px 12px;
    font-size: 0.9rem;
}
.btn-nav:hover { background-color: #dbeafe; }

#alertBox {
    display: none;
    background-color: var(--danger-bg);
    border-left: 5px solid var(--danger);
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 24px;
    color: #991b1b;
}

#alertBox h3 {
    margin-bottom: 6px;
    font-size: 1rem;
}

#alertBox ul {
    margin-left: 20px;
}

.schedules-container {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.schedule-card {
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    overflow: hidden;
    border: 1px solid var(--border);
    border-left: 6px solid var(--primary);
}

.schedule-header {
    padding: 12px 20px;
    font-weight: bold;
    font-size: 1.1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    text-align: center;
}

th, td {
    border: 1px solid var(--border);
    padding: 8px;
    min-width: 125px;
    transition: background-color 0.2s ease;
}

th {
    background-color: #f8fafc;
    font-weight: 600;
}

th .day-subdate {
    display: block;
    font-size: 0.78rem;
    font-weight: normal;
    color: #64748b;
    margin-top: 2px;
}

td.session-label {
    font-weight: bold;
    background-color: #f8fafc;
    width: 85px;
    min-width: 85px;
}

select.slot-select {
    font-weight: 600;
    border-radius: 4px;
    transition: all 0.2s;
}

select.conflict {
    border: 2px solid var(--danger) !important;
    background-color: var(--danger-bg) !important;
    color: var(--danger) !important;
    font-weight: bold !important;
}

.teacher-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.9rem;
    border: 1px solid rgba(0,0,0,0.1);
}

.class-badge-preview {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.95rem;
    border: 1px solid rgba(0,0,0,0.1);
}

.empty-slot {
    color: #94a3b8;
    font-size: 0.85rem;
}

.class-week-tag {
    font-size: 0.85rem;
    padding: 3px 8px;
    border-radius: 4px;
    background: #e2e8f0;
    color: #334155;
    font-weight: 600;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    overflow-y: auto;
    padding: 20px 10px;
}

.modal-content {
    background-color: #fff;
    margin: 20px auto;
    padding: 25px;
    border-radius: 8px;
    max-width: 1100px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    position: relative;
}

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

.modal-title {
    font-size: 1.3rem;
    color: var(--primary);
    font-weight: bold;
}

.btn-close {
    background: #94a3b8;
    border: none;
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}
.btn-close:hover { background: #64748b; }

.modal-actions {
    display: flex;
    gap: 10px;
}

.export-section {
    margin-bottom: 30px;
    page-break-after: always;
}

.export-section:last-child {
    page-break-after: auto;
}

/* ==========================================================================
   CSS PRINTING SYSTEM (HỆ THỐNG ĐỊNH DẠNG IN ẤN ĐA NGỮ CẢNH CHUẨN A4)
   Hỗ trợ 2 chế độ:
   1. In Báo Cáo Thống Kê Giảng Dạy & Số Giờ Dạy (body.printing-stats-mode hoặc khi tab stats active)
   2. In Thời Khóa Biểu Xuất Lịch Theo Lớp / Giáo Viên (#modalExport)
   ========================================================================== */

/* Ẩn header in ấn trên màn hình thông thường */
.stats-print-header {
    display: none;
}

@media print {
    /* 1. MẶC ĐỊNH ẨN TẤT CẢ PHẦN TỬ KHÔNG LIÊN QUAN */
    body {
        background: #ffffff !important;
        color: #000000 !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    body * {
        visibility: hidden;
    }

    /* Các thành phần giao diện luôn ẩn khi in */
    header,
    .token-bar,
    .tabs,
    .stats-filter-container,
    .hours-config-box,
    .action-bar,
    .week-bar,
    #alertBox,
    .toast-container,
    .modal-header,
    .modal-actions,
    .btn,
    .btn-close {
        display: none !important;
    }

    /* ==========================================================================
       TRƯỜNG HỢP A: IN BÁO CÁO THỐNG KÊ (PRINT STATS REPORT)
       Kích hoạt khi: body có class 'printing-stats-mode' HOẶC tab-stats đang mở và modalExport đóng
       ========================================================================== */
    body.printing-stats-mode #statsResultArea,
    body.printing-stats-mode #statsResultArea *,
    body:not(.printing-modal-mode) #tab-stats.active #statsResultArea,
    body:not(.printing-modal-mode) #tab-stats.active #statsResultArea * {
        visibility: visible;
    }

    body.printing-stats-mode #tab-stats,
    body:not(.printing-modal-mode) #tab-stats.active {
        display: block !important;
    }

    body.printing-stats-mode #statsResultArea,
    body:not(.printing-modal-mode) #tab-stats.active #statsResultArea {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        background: #ffffff;
        padding: 10px 15px;
        margin: 0;
        box-sizing: border-box;
    }

    /* Tiêu đề in báo cáo thống kê */
    .stats-print-header {
        display: block !important;
        visibility: visible !important;
        text-align: center;
        margin-bottom: 20px;
        padding-bottom: 14px;
        border-bottom: 2px solid #0f172a;
    }

    .stats-print-header * {
        visibility: visible !important;
    }

    .stats-print-title {
        font-size: 1.5rem;
        font-weight: 800;
        color: #0f172a;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin-bottom: 4px;
    }

    .stats-print-subtitle {
        font-size: 0.95rem;
        font-weight: 600;
        color: #475569;
        margin-bottom: 12px;
    }

    .stats-print-meta-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px 16px;
        text-align: left;
        background: #f8fafc;
        border: 1px solid #cbd5e1;
        padding: 10px 14px;
        border-radius: 6px;
        font-size: 0.85rem;
    }

    .stats-print-meta-item .meta-label {
        font-weight: 600;
        color: #475569;
        margin-right: 4px;
    }

    .stats-print-meta-item .meta-val {
        font-weight: 700;
        color: #0f172a;
    }

    /* Dàn hàng 4 Thẻ KPI trên trang in */
    .stats-kpi-grid {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 12px !important;
        margin-bottom: 20px !important;
        page-break-inside: avoid;
    }

    .kpi-card {
        box-shadow: none !important;
        border: 1px solid #94a3b8 !important;
        background: #f8fafc !important;
        padding: 10px 12px !important;
        border-radius: 6px !important;
    }

    .kpi-label {
        font-size: 0.76rem !important;
        color: #475569 !important;
    }

    .kpi-value {
        font-size: 1.4rem !important;
        color: #0f172a !important;
    }

    .kpi-sub {
        font-size: 0.75rem !important;
        color: #64748b !important;
    }

    /* Các Bảng Thống Kê */
    .stats-section-box {
        box-shadow: none !important;
        border: 1px solid #64748b !important;
        border-radius: 6px !important;
        margin-bottom: 20px !important;
        page-break-inside: auto;
    }

    .stats-section-header {
        background: #f1f5f9 !important;
        border-bottom: 1px solid #64748b !important;
        padding: 8px 12px !important;
    }

    .stats-section-title {
        font-size: 0.95rem !important;
        color: #0f172a !important;
        font-weight: 700 !important;
    }

    /* MỞ RỘNG TOÀN BỘ CHIỀU CAO CHO BẢNG NHẬT KÝ CHI TIẾT (KHÔNG BỊ CẮT CUỘN) */
    .stats-table-wrapper {
        max-height: none !important;
        overflow: visible !important;
    }

    .stats-table {
        width: 100% !important;
        border-collapse: collapse !important;
    }

    .stats-table th,
    .stats-table td {
        border: 1px solid #94a3b8 !important;
        padding: 6px 8px !important;
        font-size: 0.82rem !important;
        color: #0f172a !important;
    }

    .stats-table th {
        background: #f1f5f9 !important;
        font-weight: 700 !important;
    }

    .stats-table tr {
        page-break-inside: avoid;
    }

    .progress-bar-wrap {
        display: none !important;
    }

    /* ==========================================================================
       TRƯỜNG HỢP B: IN THỜI KHÓA BIỂU THEO LỚP / GIÁO VIÊN (#modalExport)
       ========================================================================== */
    body.printing-modal-mode #modalExport,
    body.printing-modal-mode #modalExport *,
    body:not(.printing-stats-mode) #modalExport[style*="display: block"],
    body:not(.printing-stats-mode) #modalExport[style*="display: block"] * {
        visibility: visible;
    }

    #modalExport {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        background: white;
        padding: 0;
        margin: 0;
    }

    #modalExport .modal-content {
        box-shadow: none !important;
        border: none !important;
        margin: 0 !important;
        padding: 0 !important;
        max-width: 100% !important;
    }

    .schedule-card {
        box-shadow: none !important;
        border: 1px solid #000 !important;
        margin-bottom: 25px !important;
        page-break-inside: avoid;
    }

    .schedule-header {
        background: #f1f5f9 !important;
        color: #000 !important;
        border-bottom: 1px solid #000 !important;
    }

    table th, table td {
        border: 1px solid #000 !important;
    }
}

/* ==========================================================================
   CSS CHO MODULE THỐNG KÊ SỐ BUỔI VÀ GIỜ DẠY GIẢNG VIÊN
   ========================================================================== */
.stats-filter-container {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
}

.filter-mode-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.filter-mode-btn {
    padding: 7px 14px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.88rem;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s ease;
}

.filter-mode-btn:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.filter-mode-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.filter-controls-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 12px;
}

.filter-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 160px;
    flex: 1;
}

.filter-field label {
    font-size: 0.84rem;
    font-weight: 600;
    color: #334155;
}

.filter-field select,
.filter-field input {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: white;
    font-size: 0.9rem;
    outline: none;
}

.filter-field select:focus,
.filter-field input:focus {
    border-color: var(--primary);
}

.hours-config-box {
    background: white;
    border: 1px dashed #cbd5e1;
    border-radius: 6px;
    padding: 10px 14px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
    color: #334155;
    margin-top: 10px;
}

.hours-config-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.hours-input-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
}

.hours-input-item input {
    width: 60px;
    padding: 4px 6px;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.85rem;
}

.stats-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 15px;
    margin-bottom: 24px;
}

.kpi-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 18px;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.05);
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-left: 5px solid var(--primary);
}

.kpi-card.kpi-green { border-left-color: var(--success); }
.kpi-card.kpi-purple { border-left-color: var(--purple); }
.kpi-card.kpi-info { border-left-color: var(--info); }

.kpi-label {
    font-size: 0.84rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.2;
}

.kpi-sub {
    font-size: 0.8rem;
    color: #94a3b8;
}

.stats-section-box {
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 22px;
    overflow: hidden;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.05);
}

.stats-section-header {
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    padding: 12px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.stats-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.stats-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.stats-table th {
    background: #f1f5f9;
    color: #334155;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 10px 12px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.stats-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.9rem;
    vertical-align: middle;
}

.stats-table tr:hover td {
    background: #f8fafc;
}

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

.progress-bar-wrap {
    width: 100%;
    background: #e2e8f0;
    border-radius: 9999px;
    height: 8px;
    overflow: hidden;
    margin-top: 4px;
}

.progress-bar-inner {
    height: 100%;
    border-radius: 9999px;
    background: var(--primary);
    transition: width 0.3s ease;
}

.class-pill-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    margin: 2px 4px 2px 0;
    border: 1px solid rgba(0,0,0,0.08);
}

.session-badge-count {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 12px;
    background: #e0f2fe;
    color: #0369a1;
    font-size: 0.78rem;
    font-weight: 700;
}

/* ==========================================================================
   SCHEDULE TOKEN BAR & DUAL-STORAGE SYNC INDICATOR
   ========================================================================== */
.token-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 16px;
    margin-top: 14px;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
}

.token-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.token-label {
    font-size: 0.88rem;
    font-weight: 600;
    color: #475569;
}

.token-badge {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.95rem;
    font-weight: 700;
    color: #1e293b;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    padding: 4px 10px;
    border-radius: 6px;
    letter-spacing: 0.5px;
    cursor: pointer;
    user-select: all;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.token-badge:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}

.btn-token-action {
    background: #e0f2fe;
    color: #0284c7;
    border: 1px solid #bae6fd;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-token-action:hover {
    background: #bae6fd;
    color: #0369a1;
}

.btn-token-action.copied {
    background: #dcfce7;
    color: #15803d;
    border-color: #86efac;
}

.token-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-token-open {
    background: #f3e8ff;
    color: #7e22ce;
    border: 1px solid #e9d5ff;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-token-open:hover {
    background: #e9d5ff;
    color: #6b21a8;
}

/* Các nút điều khiển Đồng Bộ Chủ Động (Explicit Sync Buttons) */
.btn-sync-push {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #0284c7;
    color: #ffffff;
    border: 1px solid #0369a1;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 0.86rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.btn-sync-push:hover {
    background: #0369a1;
    border-color: #075985;
    transform: translateY(-1px);
}

/* Nổi bật khi có thay đổi chưa đồng bộ lên server (màu cam cảnh báo) */
.btn-sync-push.btn-sync-unsaved {
    background: #ea580c;
    border-color: #c2410c;
    color: #ffffff;
    animation: unsavedGlow 1.8s infinite ease-in-out;
}

.btn-sync-push.btn-sync-unsaved:hover {
    background: #c2410c;
    border-color: #9a3412;
}

.btn-sync-push.btn-sync-loading {
    opacity: 0.75;
    cursor: wait;
    pointer-events: none;
}

.btn-sync-pull {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #ffffff;
    color: #334155;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-sync-pull:hover {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #94a3b8;
}

.token-sync-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #15803d;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    padding: 5px 12px;
    border-radius: 20px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.token-sync-status .sync-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    flex-shrink: 0;
}

.token-sync-status.status-unsaved {
    color: #c2410c;
    background: #fff7ed;
    border-color: #fed7aa;
}

.token-sync-status.status-unsaved .sync-dot {
    background: #f97316;
    animation: syncPulse 1.4s infinite alternate ease-in-out;
}

.token-sync-status.status-saving {
    color: #0284c7;
    background: #f0f9ff;
    border-color: #bae6fd;
}

.token-sync-status.status-saving .sync-dot {
    background: #0ea5e9;
    animation: syncPulse 0.8s infinite alternate ease-in-out;
}

.token-sync-status.status-error {
    color: #b91c1c;
    background: #fef2f2;
    border-color: #fecaca;
}

.token-sync-status.status-error .sync-dot {
    background: #ef4444;
}

.token-sync-status.status-offline {
    color: #b45309;
    background: #fffbeb;
    border-color: #fde68a;
}

.token-sync-status.status-offline .sync-dot {
    background: #f59e0b;
}

@keyframes syncPulse {
    from { opacity: 0.4; transform: scale(0.85); }
    to { opacity: 1; transform: scale(1.2); }
}

@keyframes unsavedGlow {
    0% { box-shadow: 0 0 0 0 rgba(234, 88, 12, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(234, 88, 12, 0); }
    100% { box-shadow: 0 0 0 0 rgba(234, 88, 12, 0); }
}

/* ==========================================================================
   TOAST NOTIFICATION SYSTEM
   ========================================================================== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 380px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    font-size: 0.88rem;
    font-weight: 500;
    color: #1e293b;
    pointer-events: auto;
    opacity: 0;
    transform: translateY(-12px) scale(0.96);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.toast-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.toast.toast-hiding {
    opacity: 0;
    transform: translateY(-8px) scale(0.95);
}

.toast-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    line-height: 1.4;
}

.toast-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 0.95rem;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.toast-close:hover {
    color: #475569;
    background: #f1f5f9;
}

.toast-success {
    border-left: 4px solid #16a34a;
    background: #f0fdf4;
}

.toast-error {
    border-left: 4px solid #dc2626;
    background: #fef2f2;
}

.toast-warning {
    border-left: 4px solid #ea580c;
    background: #fff7ed;
}

.toast-info {
    border-left: 4px solid #0284c7;
    background: #f0f9ff;
}

/* ==========================================================================
   SYNC CONFLICT MODAL & OPTIMISTIC LOCKING UI
   ========================================================================== */
.conflict-alert-box {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    color: #9a3412;
    font-size: 0.9rem;
    line-height: 1.5;
}

.conflict-version-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    align-items: center;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 6px;
    padding: 8px 12px;
    margin-top: 10px;
    border: 1px solid #ffedd5;
    font-size: 0.85rem;
}

.badge-version {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.8rem;
}

.badge-version.remote {
    background: #fed7aa;
    color: #9a3412;
}

.badge-version.local {
    background: #e2e8f0;
    color: #334155;
}

.conflict-options-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 16px;
}

.conflict-card {
    border-radius: 8px;
    padding: 14px 16px;
    transition: all 0.2s ease;
}

.conflict-card.card-safe {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
}

.conflict-card.card-danger {
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.conflict-card-title {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.conflict-card.card-safe .conflict-card-title {
    color: #166534;
}

.conflict-card.card-danger .conflict-card-title {
    color: #991b1b;
}

.conflict-card-desc {
    font-size: 0.85rem;
    line-height: 1.45;
    margin-bottom: 12px;
}

.conflict-card.card-safe .conflict-card-desc {
    color: #15803d;
}

.conflict-card.card-danger .conflict-card-desc {
    color: #b91c1c;
}

.input-overwrite-confirm {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid #f87171;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    color: #7f1d1d;
    background: #ffffff;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s ease;
}

.input-overwrite-confirm:focus {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.btn-force-overwrite {
    width: 100%;
    padding: 10px;
    background: #dc2626;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 10px;
}

.btn-force-overwrite:hover:not(:disabled) {
    background: #b91c1c;
}

.btn-force-overwrite:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    background: #94a3b8;
}



