/* layout.css — App Structure (Sidebar, Navbar, Content) */

/* =============================================
   APP SHELL
   ============================================= */
.app-wrapper {
    display: flex;
    height: 100vh;
    overflow: hidden;
    background-color: var(--color-bg);
}

/* =============================================
   SIDEBAR
   ============================================= */
.app-sidebar {
    width: 240px;
    height: 100vh;
    background: #0b1220;
    border-right: 1px solid #1e293b;
    position: fixed;
    top: 0; left: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    height: 64px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid #1e293b;
    flex-shrink: 0;
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 10px;
}
.sidebar-menu::-webkit-scrollbar { width: 4px; }
.sidebar-menu::-webkit-scrollbar-thumb { background: #1e293b; }

/* =============================================
   MAIN CONTENT
   ============================================= */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* =============================================
   HEADER / NAVBAR
   ============================================= */
.app-navbar {
    height: 64px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
    position: relative;
}

/* =============================================
   CONTENT AREA
   ============================================= */
.app-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-8) var(--sp-8);
}

.container-sm {
    max-width: 520px;
    margin: 0 auto;
}
.container-md {
    max-width: 760px;
    margin: 0 auto;
}
.container-lg {
    max-width: 1160px;
    margin: 0 auto;
}

/* =============================================
   AUTH LAYOUT (Login / Register pages)
   ============================================= */
.auth-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--sp-6);
    background-color: var(--color-bg);
}

/* =============================================
   MOBILE SIDEBAR (hamburger overlay)
   ============================================= */

/* Overlay backdrop */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.25s;
}
.sidebar-overlay.visible { opacity: 1; }

/* Hamburger toggle button (hidden on desktop) */
.sidebar-toggle {
    display: none;
    background: none; border: none; cursor: pointer;
    color: var(--color-text); padding: 6px;
    border-radius: 8px; flex-shrink: 0;
}
.sidebar-toggle:hover { background: var(--color-bg); }

/* Mobile close button inside sidebar header */
.sidebar-close-btn {
    display: none;
    margin-left: auto; background: none; border: none;
    color: #94a3b8; cursor: pointer; padding: 4px;
    border-radius: 6px;
}

@media (max-width: 768px) {
    /* Narrower navbar padding on mobile */
    .app-navbar { padding: 0 16px; }
    .sidebar-toggle { display: flex; align-items: center; justify-content: center; }
    .sidebar-close-btn { display: block; }

    /* Show overlay when open */
    .sidebar-overlay { display: block; }

    /* Sidebar becomes fixed off-screen overlay */
    .app-sidebar {
        position: fixed; top: 0; left: -280px; width: 280px; height: 100%;
        transition: left 0.32s cubic-bezier(0.16,1,0.3,1);
        z-index: 200; box-shadow: 8px 0 32px rgba(0,0,0,0.25);
    }
    .app-sidebar.open { left: 0; }

    /* Content area full width */
    .app-main { min-width: 0; width: 100%; }

    .app-content { padding: 16px 12px; }
    .container-lg { max-width: 100%; padding: 0; }
}

/* =============================================
   GLOBAL COMMAND PALETTE (Cmd+K)
   ============================================= */
.search-overlay {
    position: fixed; inset: 0;
    background: rgba(15,23,42,0.45);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    z-index: 1000; display: none; padding-top: 15vh;
}
.search-overlay.active { display: flex; justify-content: center; }
.search-modal {
    width: 100%; max-width: 600px; height: fit-content;
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: 16px; box-shadow: var(--shadow-xl);
    overflow: hidden; animation: searchPop 0.25s var(--ease-spring);
}
@keyframes searchPop { from { opacity: 0; transform: scale(0.95) translateY(-10px); } }

.search-field-wrap {
    padding: 20px 24px; display: flex; align-items: center; gap: 16px;
    border-bottom: 2px solid var(--color-border);
}
#global-search-input {
    flex: 1; border: none; background: none; outline: none;
    font-size: 18px; font-weight: 600; color: var(--color-text);
    font-family: var(--font-sans);
}
#global-search-input::placeholder { color: var(--color-text-faint); }

.search-results { max-height: 400px; overflow-y: auto; padding: 8px; }
.search-item {
    display: flex; align-items: center; gap: 14px; padding: 12px 16px;
    border-radius: 10px; cursor: pointer; transition: all 0.15s;
    text-decoration: none; color: inherit;
}
.search-item:hover, .search-item.active { background: var(--color-bg); }
.search-item-icon {
    width: 36px; height: 36px; border-radius: 8px; background: var(--color-primary-light);
    color: var(--color-primary); display: flex; align-items: center; justify-content: center;
}
.search-item-title { font-size: 14px; font-weight: 700; color: var(--color-text); }
.search-item-meta  { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }

.search-footer {
    padding: 12px 24px; background: #f8fafc; border-top: 1px solid var(--color-border);
    display: flex; gap: 16px; font-size: 11px; color: var(--color-text-faint); font-weight: 600;
}
.kb-key {
    background: #fff; border: 1px solid var(--color-border); border-radius: 4px;
    padding: 2px 4px; color: var(--color-text-muted); box-shadow: 0 1px 0 rgba(0,0,0,0.1);
}
