/**
 * Dhanvi HRMS - Enterprise UI/UX Design System
 * Primary Brand: Dhanvi Gold (#B58000)
 */

/* ==========================================================================
   1. Design Tokens & Color Palette
   ========================================================================== */
:root {
    /* Brand Colors */
    --brand-primary: #B58000;
    --brand-dark: #8F6500;
    --brand-light: #D9A928;
    --brand-soft: #FFF8E5;
    --brand-glow: rgba(181, 128, 0, 0.2);

    /* Semantic Colors */
    --success: #10B981;
    --success-soft: #ECFDF5;
    --warning: #F59E0B;
    --warning-soft: #FFFBEB;
    --danger: #EF4444;
    --danger-soft: #FEF2F2;
    --info: #0EA5E9;
    --info-soft: #F0F9FF;

    /* Light Theme (Default) */
    --bg-main: #F8F9FA;
    --bg-secondary: #F1F3F5;
    --bg-card: #FFFFFF;
    --bg-surface-elevated: #FFFFFF;
    --bg-sidebar: #FFFFFF;
    --border-color: #E5E7EB;
    --border-subtle: #F3F4F6;
    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;
    --text-inverse: #FFFFFF;

    /* Sidebar Light Theme Tokens */
    --sidebar-text: #4B5563;
    --sidebar-text-active: #B58000;
    --sidebar-bg-active: #FFF8E5;
    --sidebar-border: #E5E7EB;

    /* Typography & Spacing */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.08), 0 1px 2px -1px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

    /* Dimensions */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 76px;
    --header-height: 68px;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   2. Dark Theme Tokens
   ========================================================================== */
[data-theme="dark"] {
    --bg-main: #121212;
    --bg-secondary: #1C1C1C;
    --bg-card: #242424;
    --bg-surface-elevated: #2B2B2B;
    --bg-sidebar: #181818;
    --border-color: #3A3A3A;
    --border-subtle: #2A2A2A;
    --text-primary: #F5F5F5;
    --text-secondary: #B0B0B0;
    --text-muted: #757575;
    --text-inverse: #121212;

    /* Brand Soft Dark Mode */
    --brand-soft: #2A2208;
    --brand-glow: rgba(217, 169, 40, 0.25);

    /* Sidebar Dark Tokens */
    --sidebar-text: #B0B0B0;
    --sidebar-text-active: #D9A928;
    --sidebar-bg-active: #2A2208;
    --sidebar-border: #2D2D2D;

    /* Semantic Softs Dark Mode */
    --success-soft: #064E3B;
    --warning-soft: #78350F;
    --danger-soft: #7F1D1D;
    --info-soft: #0C4A6E;

    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.7);
}

/* ==========================================================================
   3. Base & Reset
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    font-size: 0.925rem;
    -webkit-font-smoothing: antialiased;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

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

a:hover {
    color: var(--brand-light);
}

/* ==========================================================================
   4. App Shell Layout
   ========================================================================== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    background-color: var(--bg-main);
}

/* ==========================================================================
   5. Sidebar Navigation
   ========================================================================== */
.app-sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: width var(--transition-normal), transform var(--transition-normal), background-color var(--transition-normal);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--sidebar-border);
    gap: 0.75rem;
    position: sticky;
    top: 0;
    background-color: var(--bg-sidebar);
    z-index: 10;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    overflow: hidden;
}

.sidebar-logo img {
    height: 38px;
    width: auto;
    object-fit: contain;
    border-radius: var(--radius-xs);
}

.brand-text-wrapper {
    display: flex;
    flex-direction: column;
    white-space: nowrap;
}

.brand-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--brand-primary);
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.brand-tagline {
    font-size: 0.68rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.sidebar-menu {
    list-style: none;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.menu-header {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 0.85rem 0.75rem 0.35rem;
}

.menu-item > a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    color: var(--sidebar-text);
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.9rem;
    position: relative;
    transition: all var(--transition-fast);
}

.menu-item > a:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.menu-item.active > a {
    background-color: var(--sidebar-bg-active);
    color: var(--sidebar-text-active);
    font-weight: 600;
}

.menu-item.active > a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 15%;
    height: 70%;
    width: 3.5px;
    background-color: var(--brand-primary);
    border-radius: 0 4px 4px 0;
}

.menu-icon {
    font-size: 1.15rem;
    width: 22px;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Submenu & Expand/Collapse Accordion Navigation */
.has-submenu .submenu-toggle {
    cursor: pointer;
    user-select: none;
    width: 100%;
}

.submenu-arrow {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: transform var(--transition-normal);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.has-submenu.open > .submenu-toggle .submenu-arrow {
    transform: rotate(180deg);
    color: var(--brand-primary);
}

.submenu {
    list-style: none;
    padding: 0.25rem 0 0.35rem 0;
    margin-left: 1.5rem;
    border-left: 1.5px solid var(--border-color);
    display: none;
    flex-direction: column;
    gap: 0.15rem;
}

.has-submenu.open > .submenu {
    display: flex;
}

.submenu-item a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.75rem;
    margin-left: 0.4rem;
    color: var(--sidebar-text);
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.84rem;
    transition: all var(--transition-fast);
}

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

.submenu-item.active a {
    background-color: var(--sidebar-bg-active);
    color: var(--sidebar-text-active);
    font-weight: 600;
}

body[data-sidebar="collapsed"] .submenu {
    display: none !important;
}

body[data-sidebar="collapsed"] .submenu-arrow {
    display: none;
}

/* ==========================================================================
   6. Main Content & Header
   ========================================================================== */
.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--transition-normal);
}

.app-header {
    height: var(--header-height);
    background-color: var(--bg-surface-elevated);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.75rem;
    position: sticky;
    top: 0;
    z-index: 90;
    transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.nav-toggle-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

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

/* Global Search Bar in Header */
.header-search {
    position: relative;
    width: 280px;
}

.header-search input {
    width: 100%;
    padding: 0.5rem 0.85rem 0.5rem 2.2rem;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.header-search input:focus {
    outline: none;
    background-color: var(--bg-card);
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-glow);
    width: 340px;
}

.header-search .search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
    pointer-events: none;
}

.header-search .search-kbd {
    position: absolute;
    right: 0.65rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    color: var(--text-muted);
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1px 5px;
    pointer-events: none;
}

/* Theme Switcher Dropdown */
.theme-switch-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.theme-switch-btn:hover {
    background-color: var(--bg-secondary);
    color: var(--brand-primary);
}

.theme-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    padding: 0.35rem;
    display: none;
    flex-direction: column;
    gap: 2px;
    z-index: 110;
}

.theme-menu.show {
    display: flex;
}

.theme-option {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-xs);
    font-size: 0.85rem;
    color: var(--text-primary);
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    transition: background-color var(--transition-fast);
}

.theme-option:hover {
    background-color: var(--bg-secondary);
}

.theme-option.active {
    color: var(--brand-primary);
    font-weight: 600;
    background-color: var(--brand-soft);
}

/* User Profile Badge */
.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    cursor: pointer;
    padding: 0.3rem 0.5rem;
    border-radius: var(--radius-md);
    transition: background-color var(--transition-fast);
}

.user-profile-badge:hover {
    background-color: var(--bg-secondary);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background-color: var(--brand-soft);
    color: var(--brand-primary);
    border: 1.5px solid var(--brand-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.88rem;
}

/* Page Content */
.app-content {
    padding: 1.75rem;
    flex: 1;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.88rem;
    margin-top: 0.15rem;
}

.page-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

/* Footer */
.app-footer {
    padding: 1rem 1.75rem;
    background-color: var(--bg-surface-elevated);
    border-top: 1px solid var(--border-color);
    font-size: 0.84rem;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color var(--transition-normal), border-color var(--transition-normal);
}
