:root {
    --bg-color: #f8f9fa;
    --text-color: #333;
    --card-bg: #ffffff;
    --sidebar-bg: #e9ecef;
    --primary-color: #007bff;
    --primary-hover: #0056b3;
    --danger-color: #dc3545;
    --border-color: #dee2e6;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --ai-bg: #f0f7ff;
    --ai-border: #cce5ff;
}

/* Theme System - Multiple Dark Modes with Unique Gradients */
[data-theme="dark"] {
    --bg-color: #0f172a;
    --text-color: #f1f5f9;
    --card-bg: #1e293b;
    --sidebar-bg: #1e293b;
    --primary-color: #38bdf8;
    --primary-hover: #0ea5e9;
    --danger-color: #ef4444;
    --border-color: #334155;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    --ai-bg: #1e293b;
    --ai-border: #38bdf8;
    --header-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 40%, #334155 80%, #475569 100%);
    --sidebar-gradient: linear-gradient(180deg, #1e293b 0%, #334155 30%, #475569 60%, #334155 90%, #1e293b 100%);
    --body-gradient: linear-gradient(180deg, #0f172a 0%, #1e293b 20%, #334155 40%, #475569 60%, #334155 80%, #1e293b 100%);
    --logout-hover: linear-gradient(135deg, #ef4444 0%, #dc2626 50%, #b91c1c 100%);
    --ai-btn-gradient: linear-gradient(135deg, #38bdf8 0%, #0ea5e9 50%, #0284c7 100%);
    --primary-btn-gradient: linear-gradient(135deg, #3b82f6 0%, #2563eb 50%, #1d4ed8 100%);
    --nav-hover-gradient: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
}

[data-theme="purple"] {
    --bg-color: #1a0b2e;
    --text-color: #e9d5ff;
    --card-bg: #2d1b4e;
    --sidebar-bg: #2d1b4e;
    --primary-color: #a855f7;
    --primary-hover: #9333ea;
    --danger-color: #f43f5e;
    --border-color: #4c1d95;
    --shadow: 0 4px 12px rgba(168, 85, 247, 0.3);
    --ai-bg: #2d1b4e;
    --ai-border: #a855f7;
    --header-gradient: linear-gradient(135deg, #1a0b2e 0%, #2d1b4e 35%, #4c1d95 70%, #6b21a8 100%);
    --sidebar-gradient: linear-gradient(180deg, #2d1b4e 0%, #4c1d95 25%, #6b21a8 50%, #7e22ce 75%, #4c1d95 100%);
    --body-gradient: linear-gradient(180deg, #1a0b2e 0%, #2d1b4e 15%, #4c1d95 30%, #6b21a8 45%, #4c1d95 60%, #2d1b4e 75%, #1a0b2e 100%);
    --logout-hover: linear-gradient(135deg, #f43f5e 0%, #e11d48 50%, #be185d 100%);
    --ai-btn-gradient: linear-gradient(135deg, #c084fc 0%, #a855f7 50%, #9333ea 100%);
    --primary-btn-gradient: linear-gradient(135deg, #a855f7 0%, #9333ea 50%, #7e22ce 100%);
    --nav-hover-gradient: linear-gradient(135deg, #9333ea 0%, #7e22ce 100%);
}

[data-theme="green"] {
    --bg-color: #0a1f0a;
    --text-color: #d1fae5;
    --card-bg: #1a3a1a;
    --sidebar-bg: #1a3a1a;
    --primary-color: #10b981;
    --primary-hover: #059669;
    --danger-color: #f59e0b;
    --border-color: #166534;
    --shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    --ai-bg: #1a3a1a;
    --ai-border: #10b981;
    --header-gradient: linear-gradient(135deg, #0a1f0a 0%, #1a3a1a 30%, #166534 60%, #065f46 90%, #047857 100%);
    --sidebar-gradient: linear-gradient(180deg, #1a3a1a 0%, #166534 20%, #065f46 40%, #047857 60%, #065f46 80%, #166534 100%);
    --body-gradient: linear-gradient(180deg, #0a1f0a 0%, #1a3a1a 12%, #166534 25%, #065f46 37%, #047857 50%, #065f46 62%, #166534 75%, #1a3a1a 87%, #0a1f0a 100%);
    --logout-hover: linear-gradient(135deg, #f59e0b 0%, #d97706 50%, #b45309 100%);
    --ai-btn-gradient: linear-gradient(135deg, #34d399 0%, #10b981 50%, #059669 100%);
    --primary-btn-gradient: linear-gradient(135deg, #10b981 0%, #059669 50%, #047857 100%);
    --nav-hover-gradient: linear-gradient(135deg, #059669 0%, #047857 100%);
}

[data-theme="red"] {
    --bg-color: #1f0a0a;
    --text-color: #fee2e2;
    --card-bg: #3a1a1a;
    --sidebar-bg: #3a1a1a;
    --primary-color: #ef4444;
    --primary-hover: #dc2626;
    --danger-color: #f97316;
    --border-color: #7f1d1d;
    --shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
    --ai-bg: #3a1a1a;
    --ai-border: #ef4444;
    --header-gradient: linear-gradient(135deg, #1f0a0a 0%, #3a1a1a 25%, #7f1d1d 50%, #991b1b 75%, #b91c1c 100%);
    --sidebar-gradient: linear-gradient(180deg, #3a1a1a 0%, #7f1d1d 15%, #991b1b 30%, #b91c1c 45%, #991b1b 60%, #7f1d1d 75%, #3a1a1a 100%);
    --body-gradient: linear-gradient(180deg, #1f0a0a 0%, #3a1a1a 10%, #7f1d1d 20%, #991b1b 30%, #b91c1c 40%, #991b1b 50%, #7f1d1d 60%, #3a1a1a 70%, #1f0a0a 100%);
    --logout-hover: linear-gradient(135deg, #f97316 0%, #ea580c 50%, #c2410c 100%);
    --ai-btn-gradient: linear-gradient(135deg, #f87171 0%, #ef4444 50%, #dc2626 100%);
    --primary-btn-gradient: linear-gradient(135deg, #ef4444 0%, #dc2626 50%, #b91c1c 100%);
    --nav-hover-gradient: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
}

[data-theme="blue"] {
    --bg-color: #0a1628;
    --text-color: #dbeafe;
    --card-bg: #1e3a5f;
    --sidebar-bg: #1e3a5f;
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --danger-color: #f59e0b;
    --border-color: #1e40af;
    --shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    --ai-bg: #1e3a5f;
    --ai-border: #3b82f6;
    --header-gradient: linear-gradient(135deg, #0a1628 0%, #1e3a5f 33%, #1e40af 66%, #1e3a8a 100%);
    --sidebar-gradient: linear-gradient(180deg, #1e3a5f 0%, #1e40af 22%, #1e3a8a 44%, #1e40af 66%, #1e3a5f 88%, #1e40af 100%);
    --body-gradient: linear-gradient(180deg, #0a1628 0%, #1e3a5f 18%, #1e40af 36%, #1e3a8a 54%, #1e40af 72%, #1e3a5f 90%, #0a1628 100%);
    --logout-hover: linear-gradient(135deg, #f59e0b 0%, #d97706 50%, #b45309 100%);
    --ai-btn-gradient: linear-gradient(135deg, #60a5fa 0%, #3b82f6 50%, #2563eb 100%);
    --primary-btn-gradient: linear-gradient(135deg, #3b82f6 0%, #2563eb 50%, #1d4ed8 100%);
    --nav-hover-gradient: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}

[data-theme="orange"] {
    --bg-color: #1f1408;
    --text-color: #fed7aa;
    --card-bg: #3a2815;
    --sidebar-bg: #3a2815;
    --primary-color: #f97316;
    --primary-hover: #ea580c;
    --danger-color: #ef4444;
    --border-color: #7c2d12;
    --shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
    --ai-bg: #3a2815;
    --ai-border: #f97316;
    --header-gradient: linear-gradient(135deg, #1f1408 0%, #3a2815 28%, #7c2d12 56%, #9a3412 84%, #c2410c 100%);
    --sidebar-gradient: linear-gradient(180deg, #3a2815 0%, #7c2d12 18%, #9a3412 36%, #c2410c 54%, #9a3412 72%, #7c2d12 90%, #3a2815 100%);
    --body-gradient: linear-gradient(180deg, #1f1408 0%, #3a2815 14%, #7c2d12 28%, #9a3412 42%, #c2410c 56%, #9a3412 70%, #7c2d12 84%, #3a2815 100%);
    --logout-hover: linear-gradient(135deg, #ef4444 0%, #dc2626 50%, #b91c1c 100%);
    --ai-btn-gradient: linear-gradient(135deg, #fb923c 0%, #f97316 50%, #ea580c 100%);
    --primary-btn-gradient: linear-gradient(135deg, #f97316 0%, #ea580c 50%, #c2410c 100%);
    --nav-hover-gradient: linear-gradient(135deg, #ea580c 0%, #c2410c 100%);
}

[data-theme="pink"] {
    --bg-color: #1f0f1f;
    --text-color: #fce7f3;
    --card-bg: #3a1f3a;
    --sidebar-bg: #3a1f3a;
    --primary-color: #ec4899;
    --primary-hover: #db2777;
    --danger-color: #f43f5e;
    --border-color: #831843;
    --shadow: 0 4px 12px rgba(236, 72, 153, 0.3);
    --ai-bg: #3a1f3a;
    --ai-border: #ec4899;
    --header-gradient: linear-gradient(135deg, #1f0f1f 0%, #3a1f3a 22%, #831843 44%, #9f1239 66%, #be185d 100%);
    --sidebar-gradient: linear-gradient(180deg, #3a1f3a 0%, #831843 16%, #9f1239 32%, #be185d 48%, #9f1239 64%, #831843 80%, #3a1f3a 100%);
    --body-gradient: linear-gradient(180deg, #1f0f1f 0%, #3a1f3a 11%, #831843 22%, #9f1239 33%, #be185d 44%, #9f1239 55%, #831843 66%, #3a1f3a 77%, #1f0f1f 100%);
    --logout-hover: linear-gradient(135deg, #f43f5e 0%, #e11d48 50%, #be185d 100%);
    --ai-btn-gradient: linear-gradient(135deg, #f472b6 0%, #ec4899 50%, #db2777 100%);
    --primary-btn-gradient: linear-gradient(135deg, #ec4899 0%, #db2777 50%, #be185d 100%);
    --nav-hover-gradient: linear-gradient(135deg, #db2777 0%, #be185d 100%);
}

[data-theme="cyan"] {
    --bg-color: #0a1f1f;
    --text-color: #cffafe;
    --card-bg: #1a3a3a;
    --sidebar-bg: #1a3a3a;
    --primary-color: #06b6d4;
    --primary-hover: #0891b2;
    --danger-color: #f59e0b;
    --border-color: #164e63;
    --shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
    --ai-bg: #1a3a3a;
    --ai-border: #06b6d4;
    --header-gradient: linear-gradient(135deg, #0a1f1f 0%, #1a3a3a 32%, #164e63 64%, #155e75 96%, #0e7490 100%);
    --sidebar-gradient: linear-gradient(180deg, #1a3a3a 0%, #164e63 20%, #155e75 40%, #0e7490 60%, #155e75 80%, #164e63 100%);
    --body-gradient: linear-gradient(180deg, #0a1f1f 0%, #1a3a3a 16%, #164e63 32%, #155e75 48%, #0e7490 64%, #155e75 80%, #164e63 96%, #1a3a3a 100%);
    --logout-hover: linear-gradient(135deg, #f59e0b 0%, #d97706 50%, #b45309 100%);
    --ai-btn-gradient: linear-gradient(135deg, #22d3ee 0%, #06b6d4 50%, #0891b2 100%);
    --primary-btn-gradient: linear-gradient(135deg, #06b6d4 0%, #0891b2 50%, #0e7490 100%);
    --nav-hover-gradient: linear-gradient(135deg, #0891b2 0%, #0e7490 100%);
}

[data-theme="indigo"] {
    --bg-color: #0f0a1f;
    --text-color: #e0e7ff;
    --card-bg: #1e1a3a;
    --sidebar-bg: #1e1a3a;
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --danger-color: #f43f5e;
    --border-color: #312e81;
    --shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    --ai-bg: #1e1a3a;
    --ai-border: #6366f1;
    --header-gradient: linear-gradient(135deg, #0f0a1f 0%, #1e1a3a 26%, #312e81 52%, #4338ca 78%, #4f46e5 100%);
    --sidebar-gradient: linear-gradient(180deg, #1e1a3a 0%, #312e81 17%, #4338ca 34%, #4f46e5 51%, #4338ca 68%, #312e81 85%, #1e1a3a 100%);
    --body-gradient: linear-gradient(180deg, #0f0a1f 0%, #1e1a3a 13%, #312e81 26%, #4338ca 39%, #4f46e5 52%, #4338ca 65%, #312e81 78%, #1e1a3a 91%, #0f0a1f 100%);
    --logout-hover: linear-gradient(135deg, #f43f5e 0%, #e11d48 50%, #be185d 100%);
    --ai-btn-gradient: linear-gradient(135deg, #818cf8 0%, #6366f1 50%, #4f46e5 100%);
    --primary-btn-gradient: linear-gradient(135deg, #6366f1 0%, #4f46e5 50%, #4338ca 100%);
    --nav-hover-gradient: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
}

[data-theme="emerald"] {
    --bg-color: #0a1f14;
    --text-color: #d1fae5;
    --card-bg: #1a3a2a;
    --sidebar-bg: #1a3a2a;
    --primary-color: #10b981;
    --primary-hover: #059669;
    --danger-color: #f59e0b;
    --border-color: #065f46;
    --shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    --ai-bg: #1a3a2a;
    --ai-border: #10b981;
    --header-gradient: linear-gradient(135deg, #0a1f14 0%, #1a3a2a 24%, #065f46 48%, #047857 72%, #059669 100%);
    --sidebar-gradient: linear-gradient(180deg, #1a3a2a 0%, #065f46 14%, #047857 28%, #059669 42%, #047857 56%, #065f46 70%, #1a3a2a 84%, #065f46 100%);
    --body-gradient: linear-gradient(180deg, #0a1f14 0%, #1a3a2a 10%, #065f46 20%, #047857 30%, #059669 40%, #047857 50%, #065f46 60%, #1a3a2a 70%, #0a1f14 100%);
    --logout-hover: linear-gradient(135deg, #f59e0b 0%, #d97706 50%, #b45309 100%);
    --ai-btn-gradient: linear-gradient(135deg, #34d399 0%, #10b981 50%, #059669 100%);
    --primary-btn-gradient: linear-gradient(135deg, #10b981 0%, #059669 50%, #047857 100%);
    --nav-hover-gradient: linear-gradient(135deg, #059669 0%, #047857 100%);
}

/* Theme Selector Styles */
.theme-selector {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    min-width: 150px;
    max-height: 400px;
    overflow-y: auto;
}

.theme-selector.hidden {
    display: none;
}

.theme-option {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.theme-option:last-child {
    border-bottom: none;
}

.theme-option:hover {
    background: var(--bg-color);
    color: var(--primary-color);
}

.theme-option.active {
    background: var(--primary-color);
    color: white;
}

/* Style chung cho các nút điều hướng trong Header */
.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-nav,
.btn-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    text-decoration: none;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-color);
    cursor: pointer;
}

/* Hiệu ứng riêng cho nút Quản lý */
.btn-nav:hover {
    background: var(--nav-hover-gradient, var(--primary-color));
    border-color: transparent;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Hiệu ứng riêng cho nút Đăng xuất */
.btn-logout {
    border: 1px solid var(--danger-color);
    color: var(--danger-color);
}

.btn-logout:hover {
    background: var(--logout-hover, var(--danger-color));
    color: white;
    box-shadow: 0 0 15px rgba(255, 77, 77, 0.5);
    transform: translateY(-2px);
    border-color: transparent;
}

/* Ẩn chữ trên màn hình nhỏ để tránh vỡ layout */
@media (max-width: 600px) {

    .btn-nav .text,
    .btn-logout .text {
        display: none;
    }

    .btn-nav,
    .btn-logout {
        padding: 8px;
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: var(--body-gradient, var(--bg-color));
    background-attachment: fixed;
    color: var(--text-color);
    transition: all 0.3s ease;
    overflow: hidden;
    /* Prevent body scroll, handle inside app-container */
    min-height: 100vh;
}

/* Login Page Styles */
/* Login Page Styles - Updated to Dark Theme */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #0f172a;
    /* User's preferred dark bg */
    font-family: 'Segoe UI', sans-serif;
    margin: 0;
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    padding: 3rem;
    border-radius: 16px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    text-align: center;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    animation: fadeIn 0.5s ease-out;
}

.login-card .logo h1 {
    font-size: 2.2rem;
    background: -webkit-linear-gradient(#667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.login-card h2 {
    color: #333;
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.login-card p {
    color: #666;
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

.login-card input {
    width: 100%;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: border 0.3s;
    background: #f8f9fa;
}

.login-card input:focus {
    border-color: #667eea;
    outline: none;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Toast Notification */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--card-bg);
    color: var(--text-color);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-left: 5px solid var(--primary-color);
    min-width: 250px;
    animation: slideIn 0.3s ease-out;
    display: flex;
    align-items: center;
    font-size: 0.95rem;
}

.toast.error {
    border-left-color: var(--danger-color);
}

.toast.success {
    border-left-color: #2ecc71;
}

.toast.warning {
    border-left-color: #f1c40f;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateX(20px);
    }
}

/* === Modern Rainbow Button (User Provided) === */
.nut-bam-hien-dai {
    position: relative;
    padding: 16px 40px;
    font-size: 18px;
    font-weight: bold;
    color: #ffffff;
    background: transparent;
    /* Phải trong suốt để lộ cầu vồng */
    border: none;
    border-radius: 8px;
    cursor: pointer;
    overflow: hidden;
    /* Cắt gọn phần viền cầu vồng thừa */

    transition: all 0.3s ease-in-out;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    width: 100%;
    /* Ensure full width like previous btn */
    margin-top: 1rem;
}

/* 3. LỚP ĐÁY (Z-INDEX 0): ĐỘNG CƠ CẦU VỒNG XOAY */
.nut-bam-hien-dai::before {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;

    /* Dải màu cầu vồng xoay nón */
    background: conic-gradient(#ff0000, #ff7300, #fffb00, #48ff00,
            #00ffd5, #002bff, #7a00ff, #ff00c8, #ff0000);

    animation: xoay-cau-vong 1.5s linear infinite;
    z-index: 0;
    /* Ép nằm dưới cùng */
}

/* 4. LỚP GIỮA (Z-INDEX 1): LÕI NÚT BẤM CHE MÀU */
.nut-bam-hien-dai::after {
    content: "";
    position: absolute;
    inset: 3px;
    /* Ép thụt vào 3px để lộ viền cầu vồng ra */

    /* Nền gradient gốc của bạn */
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    border-radius: 6px;
    z-index: 1;
    /* Nằm đè lên cầu vồng, nhưng phải dưới chữ */
}

/* 5. LỚP TRÊN CÙNG (Z-INDEX 10): CHỮ VÀ ÁNH SÁNG LƯỚT */
.nut-bam-hien-dai span {
    position: relative;
    display: inline-block;
    z-index: 10;
    /* Kéo dòng chữ lên cao nhất để không bị ::after nuốt mất */
    color: white;
}

/* Hiệu ứng lướt sáng khi Hover (Gắn vào ::before của chữ để an toàn) */
.nut-bam-hien-dai span::before {
    content: "";
    position: absolute;
    top: -50px;
    left: -200%;
    width: 50%;
    height: 200px;
    background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: all 0.5s ease-in-out;
    z-index: 20;
}

/* Kích hoạt lướt sáng */
.nut-bam-hien-dai:hover span::before {
    left: 200%;
}

/* 6. HIỆU ỨNG VẬT LÝ KHI BẤM CHUỘT */
.nut-bam-hien-dai:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(139, 92, 246, 0.6);
}

.nut-bam-hien-dai:active {
    transform: translateY(2px);
    box-shadow: 0 5px 10px rgba(139, 92, 246, 0.4);
}

/* 7. ĐỘNG CƠ XOAY */
@keyframes xoay-cau-vong {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.login-card .btn {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    /* Background handled by .btn-rainbow if present */
    border-radius: 8px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 1rem;
}

.login-card .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(118, 75, 162, 0.4);
}

.error-msg {
    color: #e74c3c;
    margin-top: 1rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.blur-content {
    filter: blur(5px);
    pointer-events: none;
    transition: filter 0.3s;
}

.blur-content.active {
    filter: none;
    pointer-events: all;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

/* Header */
.main-header {
    background: var(--header-gradient, var(--card-bg));
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    z-index: 100;
    transition: all 0.3s ease;
}

.logo h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.logo span {
    color: var(--text-color);
}

.search-bar {
    flex-grow: 1;
    margin: 0 2rem;
    position: relative;
    max-width: 600px;
    display: flex;
    gap: 0.5rem;
}

.search-bar input {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: 1rem;
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s, transform 0.1s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn:active {
    transform: scale(0.98);
}

.btn.primary {
    background: var(--primary-btn-gradient, var(--primary-color));
    color: white;
    border: none;
}

.btn.primary:hover {
    background: var(--primary-btn-gradient, var(--primary-hover));
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.btn.danger {
    background-color: var(--danger-color);
    color: white;
}

.btn.sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

.btn.ai-btn {
    background: var(--ai-btn-gradient, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
    color: white;
    white-space: nowrap;
    border: none;
    transition: all 0.3s ease;
}

.btn.ai-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    filter: brightness(1.1);
}

.icon-btn {
    background: none;
    font-size: 1.2rem;
    color: var(--text-color);
}

.icon-btn:hover {
    color: var(--primary-color);
    background-color: rgba(0, 0, 0, 0.05);
}

/* Sidebar & Layout */
.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    width: 250px;
    background: var(--sidebar-gradient, var(--sidebar-bg));
    background-attachment: fixed;
    padding: 1.5rem;
    overflow-y: auto;
    border-right: 1px solid var(--border-color);
    flex-shrink: 0;
}

.filter-section h3 {
    margin-bottom: 1rem;
    font-size: 0.9rem;
    text-transform: uppercase;
    color: var(--text-color);
    opacity: 0.7;
}

.filter-list {
    list-style: none;
    margin-bottom: 2rem;
}

.filter-list li {
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
    display: flex;
    justify-content: space-between;
}

.filter-list li:hover,
.filter-list li.active {
    background: var(--nav-hover-gradient, var(--primary-color));
    color: white;
    font-weight: bold;
}

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    background-color: var(--card-bg);
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    border: 1px solid var(--border-color);
    cursor: pointer;
    color: var(--text-color);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    display: inline-block;
}

.tag::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: var(--nav-hover-gradient, var(--primary-color));
    transition: left 0.3s ease;
    z-index: 0;
}

.tag:hover {
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.tag:hover::before {
    left: 0;
}

.tag:hover span {
    color: white;
    position: relative;
    z-index: 1;
}

.tag span {
    position: relative;
    z-index: 1;
    transition: color 0.3s ease;
}

/* Content Area */
.content-area {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    position: relative;
}

/* AI Chat Area */
.ai-chat-container {
    background-color: var(--ai-bg);
    border: 1px solid var(--ai-border);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    height: 400px;
    /* Fixed height for chat */
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
    animation: slideDown 0.3s ease-out;
}

.ai-chat-container.hidden {
    display: none;
}

.ai-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--card-bg);
    border-radius: 8px 8px 0 0;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-msg {
    padding: 0.8rem;
    border-radius: 8px;
    max-width: 85%;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-msg.ai {
    background-color: var(--card-bg);
    align-self: flex-start;
    border: 1px solid var(--border-color);
}

.chat-msg.user {
    background-color: var(--primary-color);
    color: white;
    align-self: flex-end;
}

.chat-msg code {
    background-color: rgba(0, 0, 0, 0.1);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: monospace;
}

.chat-input-area {
    padding: 1rem;
    background-color: var(--card-bg);
    border-top: 1px solid var(--border-color);
    border-radius: 0 0 8px 8px;
    display: flex;
    gap: 0.5rem;
}

.chat-input-area input {
    flex: 1;
    padding: 0.8rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    color: var(--text-color);
}

/* Language Manager List */
.manage-list {
    list-style: none;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-top: 1rem;
}

.manage-list li {
    padding: 0.8rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-color);
}

.manage-list li:last-child {
    border-bottom: none;
}

.manage-list li .lang-name {
    font-weight: 600;
}

/* Grid & Cards */
.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.snippet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.snippet-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    cursor: pointer;
}

.snippet-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--primary-color);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 0.5rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--primary-color);
}

.badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    text-transform: uppercase;
    font-weight: bold;
}

.private-badge {
    background-color: #dc3545;
    color: white;
    border-color: #dc3545;
}

.public-badge {
    background-color: #28a745;
    color: white;
    border-color: #28a745;
}

.card-desc {
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.8;
    margin-bottom: 1rem;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-tags {
    display: flex;
    gap: 0.5rem;
    margin-top: auto;
    flex-wrap: wrap;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: var(--card-bg);
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.modal-content.small-modal {
    max-width: 500px;
}

.close-modal {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 1.8rem;
    cursor: pointer;
    line-height: 1;
    color: var(--text-color);
}

.close-modal:hover {
    color: var(--danger-color);
}

.modal-header h2 {
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.action-text {
    font-style: italic;
    color: var(--text-color);
    opacity: 0.7;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.modal-desc {
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

/* Code Blocks */
.code-block-container {
    margin-bottom: 1.5rem;
    background-color: #2d2d2d;
    border-radius: 4px;
    overflow: hidden;
    color: #ccc;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background-color: rgba(255, 255, 255, 0.05);
    font-size: 0.8rem;
}

pre {
    padding: 1rem;
    overflow-x: auto;
    margin: 0 !important;
}

/* Form Styles */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.form-row {
    display: flex;
    gap: 1rem;
}


/* === Modern Rainbow Button (User Provided) === */
.khung-nen-toi {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #0f172a;
    margin: 0;
}

.nut-bam-hien-dai {
    position: relative;
    padding: 16px 40px;
    font-size: 18px;
    font-weight: bold;
    color: #ffffff;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    overflow: hidden;

    transition: all 0.3s ease-in-out;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    width: 100%;
    margin-top: 1rem;
}

.nut-bam-hien-dai::before {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(#ff0000, #ff7300, #fffb00, #48ff00,
            #00ffd5, #002bff, #7a00ff, #ff00c8, #ff0000);
    animation: xoay-cau-vong 1.5s linear infinite;
    z-index: 0;
}

.nut-bam-hien-dai::after {
    content: "";
    position: absolute;
    inset: 3px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    border-radius: 6px;
    z-index: 1;
}

.nut-bam-hien-dai span {
    position: relative;
    display: inline-block;
    z-index: 10;
    color: white;
}

.nut-bam-hien-dai span::before {
    content: "";
    position: absolute;
    top: -50px;
    left: -200%;
    width: 50%;
    height: 200px;
    background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: all 0.5s ease-in-out;
    z-index: 20;
}

.nut-bam-hien-dai:hover span::before {
    left: 200%;
}

.nut-bam-hien-dai:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(139, 92, 246, 0.6);
}

.nut-bam-hien-dai:active {
    transform: translateY(2px);
    box-shadow: 0 5px 10px rgba(139, 92, 246, 0.4);
}

@keyframes xoay-cau-vong {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.8rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: 0.95rem;
}

.code-input {
    font-family: monospace;
    font-size: 0.9rem;
    background-color: #2d2d2d !important;
    color: #e0e0e0 !important;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
    margin-top: 1.5rem;
    display: flex;
    justify-content: flex-end;
}

.full-width {
    width: 100%;
}

.small-hint {
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--text-color);
    opacity: 0.7;
}

/* VS Code IDE Styles */
.vscode-btn {
    background: linear-gradient(135deg, #007acc 0%, #005a9e 100%);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.vscode-btn:hover {
    background: linear-gradient(135deg, #005a9e 0%, #004080 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 122, 204, 0.4);
}

/* IDE Modal */
.ide-modal-content {
    background: var(--card-bg);
    margin: 2% auto;
    padding: 0;
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 1400px;
    height: 90vh;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ide-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 2px solid var(--border-color);
    background: linear-gradient(135deg, #007acc 0%, #005a9e 100%);
    color: white;
}

.ide-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}

.ide-controls {
    display: flex;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--card-bg);
    flex-wrap: wrap;
    align-items: center;
}

.ide-lang-select {
    padding: 0.6rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 0.95rem;
    cursor: pointer;
}

.ide-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    min-height: 500px;
}

.ide-editor {
    flex: 1;
    min-height: 400px;
    border-bottom: 2px solid var(--border-color);
}

.ide-output {
    flex: 0 0 200px;
    display: flex;
    flex-direction: column;
    background: #1e1e1e;
    border-top: 2px solid var(--border-color);
}

.output-header {
    padding: 0.75rem 1rem;
    background: #252526;
    color: #cccccc;
    font-weight: 600;
    border-bottom: 1px solid #3e3e42;
    font-size: 0.9rem;
}

.output-content {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.9rem;
    color: #d4d4d4;
    line-height: 1.6;
}

.output-content .output-line {
    margin-bottom: 0.5rem;
    padding: 0.25rem 0;
}

.output-content .output-success {
    color: #4ec9b0;
}

.output-content .output-error {
    color: #f48771;
}

.output-content .output-info {
    color: #569cd6;
}

.output-content .output-warning {
    color: #dcdcaa;
}

/* Web Editor Container (HTML + CSS + JS) */
.web-editor-container {
    display: flex;
    flex-direction: column;
    height: 600px;
    gap: 10px;
}

.web-editor-container .web-editor-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.web-editor-container .panel-header {
    background: var(--header-bg);
    padding: 8px 12px;
    font-weight: 600;
    font-size: 13px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.web-editor-container .web-editor {
    flex: 1;
    min-height: 150px;
}

.web-output {
    flex: 0 0 350px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.web-output .output-header {
    background: var(--header-bg);
    padding: 8px 12px;
    font-weight: 600;
    font-size: 13px;
    border-bottom: 1px solid var(--border-color);
}

.web-preview-frame {
    flex: 1;
    width: 100%;
    border: none;
    background: white;
}

/* Web editor container in row layout */
.web-editor-container.rows {
    flex-direction: row;
    flex-wrap: wrap;
}

.web-editor-container.rows .web-editor-panel {
    width: calc(33% - 7px);
    height: 100%;
}

.web-editor-container.rows .web-output {
    width: 100%;
    flex: 0 0 350px;
    margin-top: 10px;
}

@media (max-width: 768px) {
    .ide-modal-content {
        width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .ide-controls {
        flex-direction: column;
    }
    
    .ide-lang-select,
    .ide-controls .btn {
        width: 100%;
    }
    
    .ide-container {
        flex-direction: column;
    }
    
    .ide-editor {
        min-height: 300px;
    }
    
    .ide-output {
        flex: 0 0 150px;
    }
}