/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #21a7eb;
    --primary-hover: #0d90dc;
    --background: #F5F5F7;
    --surface: #FFFFFF;
    --text-primary: #1D1D1F;
    --text-secondary: #86868B;
    --text-tertiary: #AEAEB2;
    --border-color: #E5E5E7;
    --hover-bg: #F5F5F7;
    --sidebar-bg: #F9F9F9;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
    --positive: #34C759;
    --neutral: #8E8E93;
    --negative: #FF3B30;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 12px;
    --spacing-lg: 16px;
    --spacing-xl: 20px;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 50%;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Inter', 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
    --sidebar-width: 120px;
    --header-height: 56px;
}

body {
    font-family: var(--font-sans);
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 13px;
    margin: 0;
    padding: 0;
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    max-height: 100vh;
    background: var(--sidebar-bg);
    padding: 0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100;
    display: flex;
    flex-direction: column;
    -webkit-overflow-scrolling: touch;
}

.sidebar-logo {
    padding: 0 var(--spacing-md);
    text-align: center;
    background: var(--surface);
    flex-shrink: 0;
    height: var(--header-height);
    min-height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-logo img {
    width: 100%;
    height: auto;
    max-height: 64px;
    object-fit: contain;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: var(--spacing-xs) 0;
    flex: 1;
    background: var(--sidebar-bg);
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    max-height: calc(100vh - var(--header-height));
    -webkit-overflow-scrolling: touch;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: var(--spacing-md) var(--spacing-xs);
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 11px;
    font-weight: 500;
    border-left: 3px solid transparent;
    position: relative;
    width: 100%;
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
    text-align: center;
}

.nav-item span {
    text-align: center;
    width: 100%;
    display: block;
}

.nav-item svg {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.nav-item:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.nav-item:hover svg {
    color: var(--text-primary);
}

.nav-item.active {
    background: transparent;
    color: var(--text-primary);
    border-left-color: var(--primary-color);
}

.nav-item.active svg {
    color: var(--primary-color);
}

.nav-item[draggable="true"] { cursor: grab; }
.nav-item[draggable="true"]:active { cursor: grabbing; }
.nav-item-dragging { opacity: 0.4; }

/* Nav Dropdown */
.nav-item-dropdown {
    position: relative;
}

@media (min-width: 769px) {
    .nav-item-dropdown:hover .nav-dropdown-menu.show,
    .nav-item-dropdown.open .nav-dropdown-menu.show {
        display: block !important;
        opacity: 1 !important;
        transform: translateX(0);
        pointer-events: all;
        visibility: visible !important;
        z-index: 10002 !important;
    }
}

.nav-item-dropdown .nav-item {
    cursor: pointer;
    background: none;
    border: none;
    width: 100%;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: var(--spacing-md) var(--spacing-xs);
    color: var(--text-primary);
    transition: all 0.2s ease;
    font-size: 11px;
    font-weight: 500;
    border-left: 3px solid transparent;
    position: relative;
    font-family: inherit;
}

.nav-item-dropdown .nav-item:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.nav-item-dropdown.open .nav-item {
    color: var(--text-primary);
}

.nav-item-dropdown.open .nav-item svg:first-of-type {
    color: var(--primary-color);
}

.nav-dropdown-menu {
    position: fixed;
    background: var(--surface) !important;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm);
    min-width: 240px;
    max-width: 320px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    display: none;
    z-index: 10002 !important;
    max-height: 80vh;
    overflow-y: auto;
    overflow-x: hidden;
    opacity: 0;
    transform: translateX(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
    left: 0;
    top: 0;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    isolation: isolate;
}

.nav-dropdown-menu.show {
    background: var(--surface) !important;
    opacity: 1 !important;
    display: block !important;
    transform: translateX(0);
    pointer-events: all;
    visibility: visible !important;
    z-index: 10002 !important;
}

.nav-dropdown-backdrop { display: none; }

@media (max-width: 768px) {
    .nav-dropdown-backdrop {
        display: block;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 10001;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s;
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }
    .nav-dropdown-backdrop.show {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }
}

.nav-dropdown-menu:has(.dropdown-search) { padding-top: 0; }

.dropdown-search {
    position: sticky;
    top: 0;
    background: var(--surface);
    padding: var(--spacing-sm);
    margin: calc(var(--spacing-sm) * -1) calc(var(--spacing-sm) * -1) var(--spacing-sm);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    z-index: 1;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    position: relative;
}

.dropdown-search svg {
    color: var(--text-secondary);
    flex-shrink: 0;
    position: absolute;
    left: calc(var(--spacing-sm) + 8px);
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    z-index: 1;
}

.dropdown-search-input {
    flex: 1;
    padding: 6px 8px 6px 28px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: var(--font-sans);
    background: rgba(0, 0, 0, 0.02);
    color: var(--text-primary);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.dropdown-search-input:hover {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.15);
}

.dropdown-search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.dropdown-search-input::placeholder { color: var(--text-secondary); }

.nav-dropdown-item.hidden { display: none; }

.nav-dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 10px var(--spacing-md);
    color: var(--text-primary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    font-size: 13px;
    white-space: nowrap;
    background: var(--surface);
}

.nav-dropdown-item:hover:not(.active):not([data-active="true"]) {
    background: var(--hover-bg);
    color: var(--primary-color);
}

.nav-dropdown-item.active,
.nav-dropdown-item[data-active="true"] {
    background: rgba(33, 167, 235, 0.1) !important;
    color: #21a7eb !important;
    font-weight: 500 !important;
}

.nav-dropdown-item.active:hover,
.nav-dropdown-item[data-active="true"]:hover {
    background: rgba(33, 167, 235, 0.15) !important;
    color: #21a7eb !important;
}

.nav-dropdown-menu::-webkit-scrollbar { width: 6px; }
.nav-dropdown-menu::-webkit-scrollbar-track { background: transparent; }
.nav-dropdown-menu::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }
.nav-dropdown-menu::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* Main Wrapper */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: var(--surface);
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-xl);
    position: sticky;
    top: 0;
    z-index: 90;
    min-width: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    flex-wrap: wrap;
    min-width: 0;
}

/* Content Area */
.content-area {
    flex: 1;
    padding: var(--spacing-lg);
}

.content-area-admin {
    padding: var(--spacing-xl) var(--spacing-lg);
}

.page-title-header {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.2;
}

/* Site Footer */
.site-footer {
    padding: 12px var(--spacing-lg);
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px 16px;
    margin-top: auto;
}

.site-footer-text,
.site-footer a {
    font-size: 11px;
    color: var(--text-tertiary);
    text-decoration: none;
    white-space: nowrap;
}

.site-footer a:hover { color: var(--text-secondary); text-decoration: underline; }
.site-footer-sep { font-size: 11px; color: var(--border-color); }

@media (max-width: 768px) {
    .site-footer { flex-direction: column; gap: 4px; text-align: center; }
    .site-footer-sep { display: none; }
}
