/* =========================================
   LAYOUT.CSS (Core, Themes, Sidebar, Header)
   ========================================= */

/* 1. Remove the blue flash when tapping links/buttons on mobile */
* {
    -webkit-tap-highlight-color: transparent;
}

/* 2. Disable the "Pull-to-Refresh" browser behavior */
html, body {
    overscroll-behavior-y: contain;
}

/* --- 1. CSS VARIABLES (Themes) --- */
:root {
    --bg-color: #F8FAFC;      
    --surface: #FFFFFF;       
    --text-main: #0F172A;     
    --text-muted: #64748B;    
    --border: #E2E8F0;        
    --accent: #2563EB;        
    --btn-bg: #0F172A;
    --btn-text: #FFFFFF;
    --btn-hover: #1E293B;
    --radius-lg: 12px;
    --radius-md: 8px;
    --shadow-soft: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --sidebar-width: 260px;
}

[data-theme="dark"] {
    --bg-color: #0B0F19;      
    --surface: #111827;       
    --text-main: #F8FAFC;     
    --text-muted: #94A3B8;    
    --border: #1F2937;        
    --accent: #3B82F6;        
    --btn-bg: #FFFFFF;
    --btn-text: #0F172A;
    --btn-hover: #E2E8F0;
    --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
    --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

/* --- 2. RESET & BASE --- */
* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Plus Jakarta Sans', sans-serif; }
body { background-color: var(--bg-color); color: var(--text-main); transition: background-color 0.3s, color 0.3s; }
.dashboard-layout { display: flex; min-height: 100vh; overflow-x: hidden; }

/* --- 3. SIDEBAR --- */
.sidebar { width: var(--sidebar-width); background: var(--surface); border-right: 1px solid var(--border); padding: 24px 16px; position: fixed; height: 100vh; transition: all 0.3s ease; z-index: 100; overflow: hidden; display: flex; flex-direction: column; }
.sidebar-header { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; padding: 0 8px; white-space: nowrap; }
.brand-icon { color: var(--accent); width: 24px; height: 24px; flex-shrink: 0; }
.sidebar-header h2 { font-size: 20px; font-weight: 700; transition: opacity 0.2s; }
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; min-height: 0; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 12px; color: var(--text-muted); text-decoration: none; font-weight: 500; font-size: 14px; border-radius: var(--radius-md); transition: all 0.2s ease; white-space: nowrap; }
.nav-item i, .brand-icon { flex-shrink: 0; width: 18px; height: 18px; }
.nav-item:hover { background: var(--bg-color); color: var(--text-main); }
.nav-item.active { background: rgba(59, 130, 246, 0.1); color: var(--accent); font-weight: 600; }
.nav-text { white-space: nowrap; transition: opacity 0.2s ease, width 0.2s ease; }
.preload * {
    transition: none !important;
}
/* Sidebar Collapse Fix */
.sidebar.collapsed { width: 80px; padding: 24px 12px; }
.sidebar.collapsed .sidebar-header { justify-content: center; padding: 0; gap: 0; }
.sidebar.collapsed .sidebar-header h2 { opacity: 0; width: 0; overflow: hidden; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 12px; gap: 0; }
.sidebar.collapsed .nav-text { opacity: 0; width: 0; overflow: hidden; }

/* --- 4. MAIN CONTENT & HEADER --- */
.main-content { flex: 1; margin-left: var(--sidebar-width); display: flex; flex-direction: column; transition: margin-left 0.3s ease; width: 100%; }
.sidebar.collapsed ~ .main-content { margin-left: 80px; }

.top-header { background: var(--surface); border-bottom: 1px solid var(--border); height: 72px; padding: 0 32px; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 50; transition: background-color 0.3s ease; }
.header-left, .header-right { display: flex; align-items: center; gap: 20px; }

/* Global UI Elements */
.icon-btn { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 8px; border-radius: var(--radius-md); transition: 0.2s; }
.icon-btn:hover { color: var(--text-main); background: var(--bg-color); }
.search-bar { display: flex; align-items: center; background: var(--bg-color); padding: 8px 16px; border-radius: var(--radius-md); border: 1px solid transparent; gap: 10px; }
.search-bar:focus-within { border-color: var(--border); background: var(--surface); }
.search-bar i { color: var(--text-muted); width: 18px; height: 18px; }
.search-bar input { border: none; outline: none; background: transparent; width: 240px; color: var(--text-main); }
.admin-profile { display: flex; align-items: center; gap: 12px; border-left: 1px solid var(--border); padding-left: 20px; }
.avatar { width: 36px; height: 36px; border-radius: var(--radius-md); background: var(--bg-color); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-weight: 600; }
.admin-info { display: flex; flex-direction: column; }
.admin-name { font-weight: 600; font-size: 13px; }
.admin-role { font-size: 12px; color: var(--text-muted); }

/* Global Content Wrappers & Buttons */
.content-wrapper { padding: 32px; max-width: 1400px; margin: 0 auto; width: 100%; }
.page-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 32px; }
.page-header h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
.page-header p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.primary-btn { background: var(--btn-bg); color: var(--btn-text); border: 1px solid transparent; padding: 10px 18px; border-radius: var(--radius-md); font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; cursor: pointer; transition: 0.2s; box-shadow: var(--shadow-soft); }
.primary-btn:hover { background: var(--btn-hover); transform: translateY(-1px); }

/* --- 5. GLOBAL RESPONSIVENESS --- */
.md-hidden { display: none; }
@media (max-width: 1024px) { .search-bar { display: none; } }
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); width: 260px; box-shadow: var(--shadow-hover); }
    .sidebar.mobile-open { transform: translateX(0); }
    .main-content, .sidebar.collapsed ~ .main-content { margin-left: 0; }
    .sidebar.collapsed { width: 260px; }
    .md-hidden { display: block; background: none; border: none; color: var(--text-muted); font-size: 20px;}
    .page-header { flex-direction: column; align-items: flex-start; gap: 16px; }
}