/**
 * TailAdmin Layout CSS - Sidebar + Top Header Layout
 * Professional Admin Dashboard Layout
 * Version: 2.0.0
 */

:root {
    --sidebar-width: 272px;
    --sidebar-collapsed-width: 72px;
    --header-height: 70px;
    --sidebar-bg: #ffffff;
    --sidebar-border: #e8edf3;
    --header-bg: #ffffff;
    --header-border: #e8edf3;
    --main-bg: #f1f5f9;
    --nav-active-bg: rgba(14, 165, 233, 0.08);
    --nav-active-color: #0ea5e9;
    --nav-hover-bg: #f8fafc;
}

/* ========== Body Layout ========== */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    overflow-x: hidden;
    /* Prevent flash of light mode - set default immediately */
    background: var(--main-bg, #f8fafc);
    transition: background-color 0.1s ease;
}

html[data-theme="dark"],
html.dark-mode {
    background: #0f172a;
}

body.with-tailadmin-layout {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--main-bg, #f8fafc);
    transition: background-color 0.1s ease;
}

body.with-tailadmin-layout[data-theme="dark"],
body.with-tailadmin-layout.dark-mode {
    background: #0f172a;
    color: #0f172a;
    display: block;
    min-height: 100vh;
    width: 100%;
    position: relative;
    overflow-x: hidden;
}

/* ========== Sidebar ========== */
.tailadmin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 1px 0 0 rgba(15, 23, 42, 0.04);
}

.tailadmin-sidebar-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 16px 12px;
    overflow: hidden;
}

/* Logo */
.tailadmin-sidebar-logo {
    margin-bottom: 16px;
    padding: 4px 8px 16px;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.tailadmin-logo-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: #0f172a;
    transition: opacity 0.2s;
    min-width: 0;
}

.tailadmin-logo-link:hover {
    opacity: 0.85;
}

.tailadmin-logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #0ea5e9 0%, #38bdf8 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.35);
}

.tailadmin-logo-text {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Sidebar Search */
.tailadmin-sidebar-search {
    margin-bottom: 12px;
    flex-shrink: 0;
    padding: 0 4px;
}

.tailadmin-sidebar-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.tailadmin-sidebar-search-icon {
    position: absolute;
    left: 10px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    pointer-events: none;
}

.tailadmin-sidebar-search-icon svg {
    width: 15px;
    height: 15px;
}

.tailadmin-sidebar-search-input {
    width: 100%;
    padding: 8px 12px 8px 34px;
    border: 1px solid var(--sidebar-border);
    border-radius: 8px;
    font-size: 13px;
    background: #f8fafc;
    color: #334155;
    transition: all 0.2s;
    box-sizing: border-box;
}

.tailadmin-sidebar-search-input::placeholder {
    color: #94a3b8;
}

.tailadmin-sidebar-search-input:focus {
    outline: none;
    border-color: #0ea5e9;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

/* Menu scroll area */
.tailadmin-sidebar-menu {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 4px;
    margin: 0 -4px;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.tailadmin-sidebar-menu::-webkit-scrollbar {
    width: 4px;
}

.tailadmin-sidebar-menu::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

/* Menu Label / Section Title */
.tailadmin-menu-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
    margin-bottom: 6px;
    margin-top: 20px;
    padding: 0 10px;
    white-space: nowrap;
    overflow: hidden;
}

.tailadmin-nav-section:first-of-type + .tailadmin-menu-label,
.tailadmin-sidebar-menu > .tailadmin-menu-label:first-child {
    margin-top: 4px;
}

.tailadmin-nav-section-title {
    user-select: none;
}

/* Navigation */
.tailadmin-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 4px;
}

.tailadmin-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    text-decoration: none;
    color: #000000;
    font-size: 13.5px;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.15s ease;
    position: relative;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border: none;
    background: transparent;
    cursor: pointer;
    width: 100%;
    text-align: left;
    font-family: inherit;
    box-sizing: border-box;
}

.tailadmin-nav-item:hover {
    background: var(--nav-hover-bg);
    color: #000000;
}

.tailadmin-nav-item.active {
    background: var(--nav-active-bg);
    color: var(--nav-active-color);
    font-weight: 600;
}

.tailadmin-nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 18px;
    background: var(--nav-active-color);
    border-radius: 0 3px 3px 0;
}

.tailadmin-nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: inherit;
    opacity: 0.75;
}

.tailadmin-nav-item.active .tailadmin-nav-icon,
.tailadmin-nav-item:hover .tailadmin-nav-icon {
    opacity: 1;
}

.tailadmin-nav-icon svg {
    width: 18px;
    height: 18px;
}

.tailadmin-nav-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13.5px;
    line-height: 1.3;
    color: #000000;
}

.tailadmin-nav-arrow {
    flex-shrink: 0;
    margin-left: auto;
    color: #94a3b8;
    display: flex;
    align-items: center;
    transition: transform 0.2s ease;
}

.tailadmin-nav-parent.expanded .tailadmin-nav-arrow {
    transform: rotate(180deg);
}

/* Nav Group (with children) */
.tailadmin-nav-group {
    display: flex;
    flex-direction: column;
}

.tailadmin-nav-parent {
    cursor: pointer;
}

.tailadmin-nav-subnav {
    display: none;
    flex-direction: column;
    gap: 1px;
    margin: 2px 0 4px 0;
    padding-left: 14px;
    border-left: 2px solid #e8edf3;
    margin-left: 19px;
}

.tailadmin-nav-subnav.open {
    display: grid;
}

.tailadmin-nav-child {
    padding: 7px 10px;
    font-size: 13px;
    font-weight: 450;
}

.tailadmin-nav-child.active {
    background: var(--nav-active-bg);
    color: var(--nav-active-color);
    font-weight: 600;
}

.tailadmin-nav-child.active::before {
    display: none;
}

/* No results */
.tailadmin-sidebar-no-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 24px 16px;
    color: #94a3b8;
    font-size: 13px;
    text-align: center;
}

.tailadmin-sidebar-no-results-icon svg {
    width: 24px;
    height: 24px;
    opacity: 0.5;
}

/* Sidebar Footer */
.tailadmin-sidebar-footer {
    flex-shrink: 0;
    padding-top: 12px;
    margin-top: 8px;
    border-top: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tailadmin-sidebar-collapse-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--sidebar-border);
    border-radius: 8px;
    background: #f8fafc;
    color: #64748b;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    width: 100%;
    font-family: inherit;
}

.tailadmin-sidebar-collapse-btn:hover {
    background: #f1f5f9;
    color: #334155;
    border-color: #cbd5e1;
}

.tailadmin-collapse-icon {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.tailadmin-collapse-label {
    white-space: nowrap;
    overflow: hidden;
}

.tailadmin-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
}

.tailadmin-sidebar-brand-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #0ea5e9 0%, #38bdf8 100%);
    color: white;
    font-size: 9px;
    font-weight: 800;
    border-radius: 6px;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

.tailadmin-sidebar-brand-text {
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
}

/* Legacy support section (removed, kept for compat) */
.tailadmin-sidebar-support {
    display: none;
}

/* ========== Top Header ========== */
.tailadmin-header {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--header-height);
    background: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
    z-index: 999;
    display: flex;
    align-items: center;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    width: calc(100% - var(--sidebar-width));
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.tailadmin-header-content {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    gap: 24px;
}

.tailadmin-header-left {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1;
}

.tailadmin-menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    color: #64748b;
    transition: all 0.2s;
}

.tailadmin-menu-toggle:hover {
    background: #f1f5f9;
    color: #0f172a;
}

/* Search */
.tailadmin-search {
    position: relative;
    flex: 1;
    max-width: 500px;
}

.tailadmin-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
}

.tailadmin-search-input {
    width: 100%;
    padding: 10px 14px 10px 44px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    background: #f8fafc;
    color: #0f172a;
    transition: all 0.2s;
}

.tailadmin-search-input:focus {
    outline: none;
    border-color: #0ea5e9;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.tailadmin-search-shortcut {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    color: #94a3b8;
    background: #ffffff;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
    pointer-events: none;
}

/* Header Right */
.tailadmin-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tailadmin-header-action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    color: #64748b;
    transition: all 0.2s;
    position: relative;
}

.tailadmin-header-action:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.tailadmin-notifications {
    position: relative;
}

.tailadmin-notification-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 18px;
    height: 18px;
    background: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: 600;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #ffffff;
}

/* User Menu */
.tailadmin-user-menu {
    position: relative;
}

.tailadmin-user-button {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    color: #0f172a;
}

.tailadmin-user-button:hover {
    background: #f1f5f9;
}

.tailadmin-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0ea5e9 0%, #38bdf8 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.tailadmin-user-name {
    font-size: 14px;
    font-weight: 500;
    color: #0f172a;
}

.tailadmin-user-arrow {
    color: #94a3b8;
    transition: transform 0.2s;
}

.tailadmin-user-menu.open .tailadmin-user-arrow {
    transform: rotate(180deg);
}

.tailadmin-user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    padding: 8px;
    display: none;
    flex-direction: column;
    z-index: 1000;
}

.tailadmin-user-dropdown.open {
    display: flex;
}

.tailadmin-user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    text-decoration: none;
    color: #64748b;
    font-size: 14px;
    border-radius: 8px;
    transition: all 0.2s;
}

.tailadmin-user-dropdown-item:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.tailadmin-user-dropdown-item svg {
    color: #94a3b8;
    flex-shrink: 0;
}

.tailadmin-user-dropdown-item.active {
    background: #f0f9ff;
    color: #0ea5e9;
    font-weight: 600;
}

.tailadmin-user-dropdown-divider {
    height: 1px;
    background: #e2e8f0;
    margin: 4px 0;
}

/* ========== Main Content ========== */
body.with-tailadmin-layout .tailadmin-main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    width: calc(100% - var(--sidebar-width));
    min-height: calc(100vh - var(--header-height));
    padding: 16px 32px 24px 32px;
    background: var(--main-bg);
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
    position: relative;
    overflow-x: hidden;
    left: 0;
    right: 0;
}

/* ========== Breadcrumbs ========== */
.tailadmin-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    margin-top: 0;
    font-size: 14px;
    color: #64748b;
}

.tailadmin-breadcrumbs a {
    color: #64748b;
    text-decoration: none;
    transition: color 0.2s;
}

.tailadmin-breadcrumbs a:hover {
    color: #0ea5e9;
}

.tailadmin-breadcrumbs-separator {
    color: #cbd5e1;
}

.tailadmin-breadcrumbs-current {
    color: #0f172a;
    font-weight: 500;
}

/* ========== Page Title ========== */
.tailadmin-page-title {
    font-size: 30px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 8px;
    margin-top: 0;
    letter-spacing: -0.02em;
}

.tailadmin-page-description {
    font-size: 16px;
    color: #64748b;
    margin-bottom: 24px;
    margin-top: 0;
}

/* ========== Collapsed Sidebar (Desktop) ========== */
body.sidebar-collapsed {
    --sidebar-width: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .tailadmin-logo-text,
body.sidebar-collapsed .tailadmin-nav-label,
body.sidebar-collapsed .tailadmin-nav-arrow,
body.sidebar-collapsed .tailadmin-nav-section-title,
body.sidebar-collapsed .tailadmin-sidebar-search,
body.sidebar-collapsed .tailadmin-collapse-label,
body.sidebar-collapsed .tailadmin-sidebar-brand-text {
    display: none;
}

body.sidebar-collapsed .tailadmin-sidebar-logo {
    padding-bottom: 12px;
    display: flex;
    justify-content: center;
}

body.sidebar-collapsed .tailadmin-logo-link {
    justify-content: center;
}

body.sidebar-collapsed .tailadmin-nav-item {
    justify-content: center;
    padding: 10px;
}

body.sidebar-collapsed .tailadmin-nav-subnav {
    display: none !important;
}

body.sidebar-collapsed .tailadmin-sidebar-collapse-btn {
    justify-content: center;
    padding: 8px;
}

body.sidebar-collapsed .tailadmin-collapse-icon {
    transform: rotate(180deg);
}

body.sidebar-collapsed .tailadmin-sidebar-brand {
    justify-content: center;
    padding: 0;
}

body.sidebar-collapsed .tailadmin-sidebar-content {
    padding: 16px 8px;
}

/* ========== Responsive ========== */
@media (max-width: 1024px) {
    .tailadmin-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1001;
    }
    
    .tailadmin-sidebar.mobile-open {
        transform: translateX(0);
    }
    
    .tailadmin-header {
        left: 0 !important;
        width: 100% !important;
    }
    
    body.with-tailadmin-layout .tailadmin-main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 20px 24px;
    }
    
    .tailadmin-menu-toggle {
        display: flex;
    }
    
    .tailadmin-search {
        max-width: 300px;
    }
    
    .tailadmin-user-name {
        display: none;
    }
}

@media (max-width: 768px) {
    .tailadmin-header-content {
        padding: 0 16px;
    }
    
    body.with-tailadmin-layout .tailadmin-main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 16px 20px;
    }
    
    .tailadmin-search {
        max-width: 200px;
    }
    
    .tailadmin-search-shortcut {
        display: none;
    }
    
    .tailadmin-sidebar {
        width: 100%;
        max-width: 280px;
    }
}

