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

:root {
    --bg-primary: #f0f4fa;
    --bg-sidebar: #ffffff;
    --bg-header: #ffffff;
    --bg-card: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e8edf5;
    --primary: #4361ee;
    --primary-hover: #3651d4;
    --primary-rgb: 67, 97, 238;
    --primary-light: rgba(67, 97, 238, 0.1);
    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.1);
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.1);
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.1);
    --info: #3b82f6;
    --info-light: rgba(59, 130, 246, 0.1);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
    --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.06);
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --header-height: 60px;
    --transition: all 0.3s ease;
    --radius: 20px;
    --radius-sm: 12px;
    --radius-lg: 24px;
}

[data-theme="dark"] {
    --bg-primary: #0c1222;
    --bg-sidebar: #141d2f;
    --bg-header: #141d2f;
    --bg-card: #1a2438;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #2a3a52;
    --primary: #5a7cf7;
    --primary-hover: #7b9aff;
    --primary-rgb: 90, 124, 247;
    --primary-light: rgba(90, 124, 247, 0.15);
    --success: #34d399;
    --success-light: rgba(52, 211, 153, 0.15);
    --danger: #f87171;
    --danger-light: rgba(248, 113, 113, 0.15);
    --warning: #fbbf24;
    --warning-light: rgba(251, 191, 36, 0.15);
    --info: #60a5fa;
    --info-light: rgba(96, 165, 250, 0.15);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.3);
    --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.25);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    font-weight: 400;
    color: var(--text-primary);
    background: var(--bg-primary);
    line-height: 1.5;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-hover);
}

img {
    max-width: 100%;
    height: auto;
}

/* ================ LAYOUT ================ */
.layout {
    display: flex;
    min-height: 100vh;
}

.main-content {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    transition: var(--transition);
    width: calc(100% - var(--sidebar-width));
}

.content-area {
    padding: 24px;
    min-height: calc(100vh - var(--header-height));
    margin-top: var(--header-height);
    display: flex;
    flex-direction: column;
}

/* ================ SIDEBAR ================ */
.sidebar {
    width: calc(var(--sidebar-width) - 24px);
    height: calc(100vh - 24px);
    position: fixed;
    top: 12px;
    left: 12px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    z-index: 1000;
    transition: var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* Sidebar flicker prevention - hide menu items until permissions loaded */
.sidebar:not(.permissions-loaded) .sidebar-item[data-module],
.sidebar:not(.permissions-loaded) .sidebar-section[data-section] {
    visibility: hidden;
}
.sidebar.permissions-loaded .sidebar-item[data-module],
.sidebar.permissions-loaded .sidebar-section[data-section] {
    visibility: visible;
}

.sidebar::-webkit-scrollbar {
    display: none;
}

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-brand img {
    height: 32px;
    margin-right: 10px;
}

.sidebar-brand span {
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 700;
}

.sidebar-nav {
    padding: 12px 0;
}

.sidebar-section {
    padding: 12px 20px 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    font-weight: 600;
}

.sidebar-item {
    display: flex;
    align-items: center;
    padding: 0 16px;
    height: 40px;
    margin: 2px 8px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    transition: var(--transition);
    cursor: pointer;
    text-decoration: none;
}

.sidebar-item:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.sidebar-item.active {
    background: var(--primary);
    color: #fff;
    font-weight: 500;
}

.sidebar-item i {
    font-size: 18px;
    margin-right: 10px;
    width: 20px;
    text-align: center;
}

/* ================ HEADER ================ */
.header {
    height: var(--header-height);
    background: var(--bg-primary);
    border-bottom: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    z-index: 999;
    transition: var(--transition);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-left h4 {
    margin: 0;
    font-size: 18px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.theme-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    height: 36px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
    font-weight: 500;
}

.theme-toggle i {
    font-size: 16px;
}

.theme-toggle:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

.admin-profile {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    position: relative;
}

.admin-profile:hover {
    background: var(--primary-light);
}

.admin-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}

.admin-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.profile-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 220px;
    display: none;
    z-index: 1001;
    padding: 8px 0;
    margin-top: 8px;
}

.profile-dropdown.show {
    display: block;
}

.profile-dropdown a,
.profile-dropdown button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    width: 100%;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
}

.profile-dropdown a:hover,
.profile-dropdown button:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.profile-dropdown .divider {
    border-top: 1px solid var(--border-color);
    margin: 4px 0;
}

.admin-footer {
    padding: 24px;
    margin-top: auto;
    border-top: 1px solid var(--border-color);
    background: var(--bg-primary);
    text-align: center;
    width: calc(100% - var(--sidebar-width));
    transition: var(--transition);
}

.sidebar-collapsed .admin-footer {
    width: calc(100% - var(--sidebar-collapsed));
}

.admin-footer p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

.admin-footer a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

.admin-footer a:hover {
    text-decoration: underline;
}
