@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&display=swap');

/* --- 1. Theme Variables (Light Mode: Ice Blue Glass) --- */
:root {
    /* สีหลัก: ฟ้าสว่าง ไล่เฉด */
    --primary-gradient: linear-gradient(135deg, #3b82f6 0%, #60a5fa 100%); /* Blue 500 -> 400 */
    --primary-color: #3b82f6;
    
    /* สีพื้นหลัง (โปร่งแสง) */
    --bg-body: #f0f9ff; /* Sky 50 */
    --bg-sidebar: rgba(255, 255, 255, 0.75); /* ขาวโปร่งแสง */
    --bg-card: rgba(255, 255, 255, 0.65); /* ขาวโปร่งแสง */
    --glass-border: 1px solid rgba(255, 255, 255, 0.8);
    
    /* ข้อความ */
    --text-main: #334155; /* Slate 700 */
    --text-muted: #64748b; /* Slate 500 */
    --text-sidebar: #334155; /* สีข้อความเมนู */
    
    /* เงา */
    --shadow-card: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    --shadow-glow: 0 0 15px rgba(59, 130, 246, 0.3);
}

/* --- 2. Dark Mode Variables (เปลี่ยนทุกอย่างเมื่อกดปุ่ม) --- */
body.dark-mode {
    /* สีหลัก: น้ำเงินนีออน */
    --primary-gradient: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    
    /* สีพื้นหลัง (มืดโปร่งแสง) */
    --bg-body: #0f172a; /* Slate 900 */
    --bg-sidebar: rgba(30, 41, 59, 0.7); /* Slate 800 Glass */
    --bg-card: rgba(30, 41, 59, 0.6); /* Slate 800 Glass */
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
    
    /* ข้อความ */
    --text-main: #f1f5f9; /* Slate 100 */
    --text-muted: #94a3b8; /* Slate 400 */
    --text-sidebar: #e2e8f0;
    
    --shadow-card: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* --- 3. Base Styles --- */
body {
    background-color: var(--bg-body);
    /* พื้นหลัง Gradient จางๆ */
    background-image: 
        radial-gradient(at 0% 0%, rgba(56, 189, 248, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(125, 211, 252, 0.15) 0px, transparent 50%);
    background-attachment: fixed;
    font-family: 'Sarabun', sans-serif;
    color: var(--text-main);
    overflow: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #bae6fd; border-radius: 10px; }

/* --- Sidebar (Glassmorphism) --- */
#mainSidebar {
    background: var(--bg-sidebar);
    backdrop-filter: blur(12px); /* เบลอฉากหลัง */
    -webkit-backdrop-filter: blur(12px);
    border-right: var(--glass-border);
    box-shadow: var(--shadow-card);
    z-index: 50;
    transition: background 0.3s ease;
}

#mainSidebar .border-b { border-color: rgba(148, 163, 184, 0.2) !important; }

/* Nav Items */
.nav-item {
    color: var(--text-sidebar);
    transition: all 0.2s ease;
    border-radius: 12px;
    margin-bottom: 6px;
    border: 1px solid transparent;
    font-weight: 500;
}

.nav-item:hover:not(.active) {
    background-color: rgba(59, 130, 246, 0.1);
    color: var(--primary-color);
    transform: translateX(4px);
}

.nav-item.active {
    background: var(--primary-gradient);
    color: #ffffff !important;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
    font-weight: 600;
    border: none;
}

/* --- Header --- */
header {
    background: var(--bg-sidebar) !important;
    backdrop-filter: blur(12px);
    border-bottom: var(--glass-border) !important;
    transition: background 0.3s ease;
}
/* แก้สีข้อความ Header ให้ตาม Dark mode */
header h2, header p, header .text-slate-700, header .text-slate-500 {
    color: var(--text-main) !important;
}

/* --- Cards (Glassmorphism) --- */
.bg-white {
    background-color: var(--bg-card) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: var(--glass-border);
    border-radius: 20px !important;
    box-shadow: var(--shadow-card) !important;
    color: var(--text-main) !important;
    transition: transform 0.2s, background 0.3s;
}
.bg-white:hover { transform: translateY(-4px); }

/* แก้สี Text ภายใน Card */
.text-slate-800, .text-slate-700 { color: var(--text-main) !important; }
.text-slate-500, .text-slate-400 { color: var(--text-muted) !important; }

/* --- Buttons --- */
button#submitBtn, button#popupBookBtn, .theme-btn {
    background: var(--primary-gradient);
    color: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
    border: none;
}
button:hover { filter: brightness(1.1); transform: translateY(-2px); }

/* --- Inputs --- */
input, select, textarea {
    background-color: rgba(255, 255, 255, 0.5) !important; /* โปร่งแสงนิดๆ */
    border: 1px solid rgba(148, 163, 184, 0.3) !important;
    color: var(--text-main) !important;
    border-radius: 12px !important;
}
body.dark-mode input, body.dark-mode select, body.dark-mode textarea {
    background-color: rgba(15, 23, 42, 0.5) !important; /* พื้นหลัง input มืด */
    border-color: rgba(255, 255, 255, 0.2) !important;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15) !important;
    outline: none;
}

/* --- Calendar --- */
.calendar-day {
    background: var(--bg-card);
    border: var(--glass-border);
    border-radius: 12px;
    color: var(--text-main);
}
.calendar-day:hover { border-color: var(--primary-color); box-shadow: var(--shadow-glow); z-index: 10; transform: scale(1.05); }
.calendar-day.today {
    background: rgba(59, 130, 246, 0.15);
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    font-weight: 700;
}
.calendar-day.has-booking {
    background: rgba(245, 158, 11, 0.1); /* ส้มจางๆ */
    border: 1px solid rgba(245, 158, 11, 0.5);
}

/* --- Stats --- */
#statsRoomChart .bg-blue-500 { background: var(--primary-gradient); }

/* --- Theme Widget --- */
#themeWidget {
    position: fixed; bottom: 20px; right: 20px; z-index: 100;
    background: var(--bg-card); padding: 8px; border-radius: 50px;
    display: flex; gap: 8px; align-items: center;
    box-shadow: var(--shadow-card); border: var(--glass-border);
    backdrop-filter: blur(10px);
}

.fade-in-up { animation: fadeInUp 0.4s forwards; opacity: 0; transform: translateY(20px); }
@keyframes fadeInUp { to { opacity: 1; transform: translateY(0); } }
.page { display: none; } .page.active { display: block; }
@media (max-width: 768px) { #mainSidebar { box-shadow: 5px 0 15px rgba(0,0,0,0.1); } }