/* ============================================
   COMMON DESIGN SYSTEM - Cổng Sinh Viên
   File dùng chung cho tất cả các trang
   ============================================ */

/* === Design Tokens === */
:root {
    /* Primary palette */
    --primary: #0f766e;
    --primary-dark: #134e4a;
    --primary-light: #14b8a6;

    /* Accent */
    --accent: #f59e0b;
    --accent-hover: #d97706;

    /* Semantic */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #0ea5e9;

    /* Light Mode Backgrounds */
    --body-bg: #f1f5f9;
    --card-bg: #ffffff;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: rgba(20, 184, 166, 0.1);
    --topbar-bg: #0f172a;
    --bg-dark: #0c1222;

    /* Light Mode Elements */
    --input-bg: #ffffff;
    --hover-bg: #f8fafc;
    --tag-bg: #f1f5f9;
    --swal-bg: #ffffff;

    /* Light Mode Text */
    --text-dark: #1e293b;
    --text-mid: #475569;
    --text-light: #94a3b8;

    /* Light Mode Border & Shadow */
    --border: #e2e8f0;
    --radius: 12px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
    --shadow-glow: 0 0 40px rgba(20, 184, 166, 0.15);

    /* UI Helper Variables (Light Mode) */
    --notice-info-bg: #f0f9ff; --notice-info-border: #bae6fd; --notice-info-text: #0369a1;
    --notice-success-bg: #f0fdf4; --notice-success-border: #bbf7d0; --notice-success-text: #15803d;
    --notice-warning-bg: #fffbeb; --notice-warning-border: #fde68a; --notice-warning-text: #b45309;
    --notice-danger-bg: #fef2f2; --notice-danger-border: #fca5a5; --notice-danger-text: #991b1b;
    
    --status-success-bg: #ecfdf5; --status-success-text: #059669;
    --status-danger-bg: #fef2f2; --status-danger-text: #dc2626;
    --status-warning-bg: #fffbeb; --status-warning-text: #d97706;

    /* Motion */
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    /* Dark Mode Backgrounds */
    --body-bg: #0c1222;
    --card-bg: rgba(255, 255, 255, 0.03);
    --sidebar-bg: rgba(255, 255, 255, 0.02);
    --sidebar-hover: rgba(255, 255, 255, 0.05);
    --sidebar-active: rgba(20, 184, 166, 0.1);
    --topbar-bg: #0c1222;

    /* Dark Mode Elements */
    --input-bg: rgba(255, 255, 255, 0.03);
    --hover-bg: rgba(255, 255, 255, 0.02);
    --tag-bg: rgba(255, 255, 255, 0.05);
    --swal-bg: #111827;

    /* Dark Mode Text */
    --text-dark: #f1f5f9;
    --text-mid: #cbd5e1;
    --text-light: #94a3b8;

    /* Dark Mode Border & Shadow */
    --border: rgba(255, 255, 255, 0.08);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);

    /* UI Helper Variables (Dark Mode) */
    --notice-info-bg: rgba(14, 165, 233, 0.1); --notice-info-border: rgba(14, 165, 233, 0.2); --notice-info-text: #38bdf8;
    --notice-success-bg: rgba(16, 185, 129, 0.1); --notice-success-border: rgba(16, 185, 129, 0.2); --notice-success-text: #34d399;
    --notice-warning-bg: rgba(245, 158, 11, 0.1); --notice-warning-border: rgba(245, 158, 11, 0.2); --notice-warning-text: #fbbf24;
    --notice-danger-bg: rgba(239, 68, 68, 0.1); --notice-danger-border: rgba(239, 68, 68, 0.2); --notice-danger-text: #f87171;
    
    --status-success-bg: rgba(16, 185, 129, 0.1); --status-success-text: #34d399;
    --status-danger-bg: rgba(239, 68, 68, 0.1); --status-danger-text: #f87171;
    --status-warning-bg: rgba(245, 158, 11, 0.1); --status-warning-text: #fbbf24;
}

/* === Reset & Typography === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* Responsive Typography (Tự động co giãn cỡ chữ theo màn hình) */
html {
    font-size: 16px; /* Mặc định cho PC (Desktop) */
}

@media (max-width: 1024px) {
    html {
        font-size: 15px; /* Tablet / Màn hình nhỏ */
    }
}

@media (max-width: 768px) {
    html {
        font-size: 14px; /* Mobile (Điện thoại) */
    }
}

@media (max-width: 480px) {
    html {
        font-size: 13.5px; /* Mobile nhỏ */
    }
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* === Shared Components === */

/* Card */
.card-modern {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: var(--transition);
}
.card-modern:hover {
    box-shadow: var(--shadow-md);
}

/* Badge (soft style) */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* Section title with icon */
.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.section-title .icon-circle {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}
.section-title .icon-circle.teal {
    background: rgba(20, 184, 166, 0.1);
    color: var(--primary);
}
.section-title .icon-circle.green {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

/* Notice / Alert card */
.notice-card {
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}

.notice-card h6 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 10px;
}
.notice-card ul {
    padding-left: 18px;
    margin: 0;
}
.notice-card li {
    font-size: 0.85rem;
    color: var(--text-mid);
    margin-bottom: 4px;
    line-height: 1.5;
}

/* Form fields (used in form_dangky) */
.form-field {
    margin-bottom: 24px;
}
.form-field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-mid);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
}
.form-field select,
.form-field input[type="date"],
.form-field textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    color: var(--text-dark);
    background: var(--input-bg);
    transition: var(--transition);
    outline: none;
}
.form-field select:focus,
.form-field input[type="date"]:focus,
.form-field input[type="number"]:focus,
.form-field input[type="text"]:focus,
.form-field textarea:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.25);
}

/* Remove number input spinners */
input[type="number"]::-webkit-inner-spin-button, 
input[type="number"]::-webkit-outer-spin-button { 
    -webkit-appearance: none; 
    margin: 0; 
}
input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}
.form-field textarea {
    resize: vertical;
    min-height: 100px;
}
.form-hint {
    display: block;
    font-size: 0.78rem;
    color: var(--text-light);
    margin-top: 6px;
}
.form-actions {
    padding-top: 20px;
    border-top: 1px solid var(--border);
    text-align: right;
}

/* Primary submit button */
.btn-primary-custom {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border: none;
    border-radius: 10px;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.btn-primary-custom:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(20, 184, 166, 0.3);
}
.btn-primary-custom:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
}
.btn-primary-custom:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Spinner */
.spinner-custom {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin-anim 0.6s linear infinite;
}
@keyframes spin-anim {
    to { transform: rotate(360deg); }
}

/* Table */
.table-responsive { 
    overflow-x: auto; 
    -webkit-overflow-scrolling: touch; 
    border-radius: 12px; 
    border: 1px solid var(--border); 
    box-shadow: var(--shadow-sm); 
    background: var(--card-bg);
}

.table-custom {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    white-space: nowrap;
}
.table-custom thead th {
    background: var(--primary-dark);
    color: #ffffff;
    border-bottom: none;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 14px 16px;
}
.table-custom tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table-custom tbody tr:hover { background: var(--hover-bg); }
.table-custom tbody tr:last-child td { border-bottom: none; }

/* Status badge (soft colors) */
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* Icon link buttons (table actions) */
.icon-link-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: rgba(20, 184, 166, 0.08);
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
    font-size: 0.8rem;
}
.icon-link-btn:hover {
    background: rgba(20, 184, 166, 0.15);
    transform: translateY(-1px);
}
.icon-link-btn.info {
    background: rgba(14, 165, 233, 0.08);
    color: #0284c7;
}
.icon-link-btn.info:hover {
    background: rgba(14, 165, 233, 0.15);
}

/* Profile */
.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}
.profile-section {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.profile-section-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}
.profile-section-header .icon-sm {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}
.profile-section-header .icon-sm.teal { background: rgba(20, 184, 166, 0.1); color: #0f766e; }
.profile-section-header .icon-sm.green { background: rgba(16, 185, 129, 0.1); color: #059669; }
.profile-section-header h5 { font-size: 0.9rem; font-weight: 700; color: var(--text-dark); margin: 0; }

.profile-row {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
}
.profile-row:last-child { border-bottom: none; }
.profile-row .lbl {
    width: 120px;
    flex-shrink: 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.profile-row .val {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-dark);
}
.profile-row .val .tag {
    display: inline-block;
    padding: 3px 10px;
    background: var(--tag-bg);
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-mid);
}

/* Animation */
.fade-in { animation: fadeIn 0.4s ease; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Mobile */
@media (max-width: 768px) {
    .profile-grid { grid-template-columns: 1fr; }
}

/* === Tabs UI === */
.tabs-nav {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    -ms-overflow-style: none; /* IE and Edge */
    scrollbar-width: none; /* Firefox */
}
.tabs-nav::-webkit-scrollbar {
    display: none; /* Chrome, Safari and Opera */
}
.tab-btn {
    padding: 12px 20px;
    border: none;
    background: transparent;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-light);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: -1px;
    white-space: nowrap;
}
.tab-btn:hover {
    color: var(--text-mid);
}
.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.tab-pane {
    display: none;
    animation: fadeIn 0.3s ease;
}
.tab-pane.active {
    display: block;
}

/* === Autocomplete Dropdown === */
.autocomplete-dropdown {
    position: absolute;
    width: 100%;
    max-height: 250px;
    overflow-y: auto;
    background: var(--card-bg);
    border: 1px solid var(--border);
    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);
    margin-top: 4px;
    z-index: 100;
}
.autocomplete-dropdown::-webkit-scrollbar {
    width: 6px;
}
.autocomplete-dropdown::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
.autocomplete-list {
    list-style: none;
    padding: 6px;
    margin: 0;
}
.autocomplete-list li {
    padding: 10px 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 10px;
}
.autocomplete-list li:hover {
    background: var(--hover-bg);
}
.autocomplete-list li .course-id {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary-dark);
    background: rgba(20, 184, 166, 0.1);
    padding: 3px 8px;
    border-radius: 6px;
    white-space: nowrap;
}
.autocomplete-list li .course-name {
    font-size: 0.9rem;
    color: var(--text-dark);
    font-weight: 500;
}
.autocomplete-list li.empty-msg {
    color: var(--text-light);
    cursor: default;
    justify-content: center;
    font-style: italic;
}
.autocomplete-list li.empty-msg:hover {
    background: none;
}

/* === Tags Input === */
.course-tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    background: var(--input-bg);
    min-height: 50px;
}
.course-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(20, 184, 166, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(20, 184, 166, 0.2);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--primary-dark);
}
.course-tag button {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    transition: var(--transition);
}
.course-tag button:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}
.course-tag-empty {
    color: var(--text-light);
    font-size: 0.85rem;
    padding: 6px;
}

/* === History Table & Card Views (Shared) === */

/* Desktop: show table, hide cards */
.history-table-view { display: block; }
.history-card-view { display: none; }

/* Mobile: hide table, show cards */
@media (max-width: 768px) {
    .history-table-view { display: none; }
    .history-card-view { display: block; }
}

/* === Card styles === */
.history-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
}
.history-empty i {
    font-size: 2rem;
    opacity: 0.3;
    display: block;
    margin-bottom: 10px;
}
.history-empty p {
    font-size: 0.9rem;
}

.history-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 12px;
    overflow: hidden;
    transition: var(--transition);
}
.history-card:hover {
    box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,0.06));
}

.history-card-header {
    padding: 14px 16px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    border-bottom: 1px solid var(--border);
}
.history-card-type {
    display: block;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary, #0f766e);
    margin-bottom: 4px;
}
.history-card-time {
    font-size: 0.75rem;
    color: var(--text-light, #94a3b8);
}
.history-card-time i { margin-right: 3px; }

.history-card-body {
    padding: 10px 16px;
}
.history-card-row {
    display: flex;
    align-items: flex-start;
    padding: 6px 0;
    gap: 8px;
}
.hc-label {
    flex-shrink: 0;
    width: 70px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-light, #94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding-top: 1px;
}
.hc-value {
    font-size: 0.85rem;
    color: var(--text-dark, #1e293b);
    word-break: break-word;
}

.history-card-footer {
    padding: 10px 16px 14px;
    display: flex;
    gap: 8px;
    border-top: 1px solid var(--border);
}
.hc-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    background: rgba(20, 184, 166, 0.08);
    color: var(--primary, #0f766e);
    transition: var(--transition);
}
.hc-link:hover {
    background: rgba(20, 184, 166, 0.15);
}
.hc-link.info {
    background: rgba(14, 165, 233, 0.08);
    color: #0284c7;
}
.hc-link.info:hover {
    background: rgba(14, 165, 233, 0.15);
}

/* === SweetAlert2 Custom Styling === */
div:where(.swal2-container) div:where(.swal2-popup) {
    border-radius: var(--radius) !important;
    padding: 24px !important;
    font-family: 'Inter', sans-serif !important;
    box-shadow: var(--shadow-lg) !important;
    border: 1px solid var(--border) !important;
    background: var(--swal-bg) !important;
    color: var(--text-dark) !important;
}
div:where(.swal2-container) h2:where(.swal2-title) {
    font-size: 1.4rem !important;
    color: var(--text-dark) !important;
    font-weight: 700 !important;
}
div:where(.swal2-container) div:where(.swal2-html-container) {
    font-size: 0.95rem !important;
    color: var(--text-mid) !important;
    line-height: 1.6 !important;
}
div:where(.swal2-container) button:where(.swal2-styled).swal2-confirm {
    background: var(--primary) !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    padding: 12px 32px !important;
    box-shadow: none !important;
    transition: var(--transition) !important;
}
div:where(.swal2-container) button:where(.swal2-styled).swal2-confirm:hover {
    background: var(--primary-dark) !important;
    transform: translateY(-1px) !important;
}
div:where(.swal2-container) button:where(.swal2-styled).swal2-cancel {
    background: var(--hover-bg) !important;
    color: var(--text-dark) !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    padding: 12px 28px !important;
    box-shadow: none !important;
    transition: var(--transition) !important;
}
div:where(.swal2-container) button:where(.swal2-styled).swal2-cancel:hover {
    background: var(--tag-bg) !important;
}

/* Icons styling sync */
div:where(.swal2-icon).swal2-success {
    border-color: var(--success) !important;
    color: var(--success) !important;
}
div:where(.swal2-icon).swal2-success [class^=swal2-success-line] {
    background-color: var(--success) !important;
}
div:where(.swal2-icon).swal2-success .swal2-success-ring {
    border-color: rgba(16, 185, 129, 0.2) !important;
}
div:where(.swal2-icon).swal2-error {
    border-color: var(--danger) !important;
    color: var(--danger) !important;
}
div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line] {
    background-color: var(--danger) !important;
}
div:where(.swal2-icon).swal2-info {
    border-color: var(--info) !important;
    color: var(--info) !important;
}
