:root {
    --primary-dark: #003366;
    --primary-cyan: #00B2CC;
    --primary-silver: #F5F7FA;
    --accent-orange: #FF9900;
    --text-dark: #1a1a1a;
    --text-gray: #6b7280;
    --border-color: #e5e7eb;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info-color: #0ea5e9;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-light: #e0f2fe;
    --success-light: #d1fae5;
    --warning-light: #fef3c7;
    --danger-light: #fee2e2;
    --gray-50: #f9fafb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --sidebar-width: 300px;
    --sidebar-collapsed-width: 72px;
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--primary-silver);
    color: var(--text-dark);
    line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--primary-dark);
    color: white;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    transition: width 0.2s ease;
    z-index: 100;
}

.sidebar-header {
    padding: 2rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-cyan) 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 20px;
    position: relative;
}

.logo-icon::after {
    content: '';
    position: absolute;
    bottom: 5px;
    right: 5px;
    width: 12px;
    height: 3px;
    background: var(--accent-orange);
    transform: rotate(-45deg);
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'Montserrat', sans-serif;
}

/* Company logo image (when provided) */
.logo img.company-logo {
    max-height: 40px;
    width: auto;
    display: block;
}

/* Department Selector - Removed as non-functional
.department-selector {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.department-chips {
    display: flex;
    gap: 0.5rem;
} */

.chip {
    padding: 0.5rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    background: transparent;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.chip:hover, .chip.active {
    background: var(--primary-cyan);
    border-color: var(--primary-cyan);
    color: white;
}

/* Navigation */
.nav-menu {
    padding: 1rem 0;
}

.nav-section {
    margin-bottom: 1.5rem;
}

.nav-section-title {
    padding: 0 1.5rem 0.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-item.active {
    background: rgba(0, 178, 204, 0.1);
    border-left-color: var(--primary-cyan);
    color: white;
}

.nav-icon {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
}

/* Collapsed sidebar state */
.app-container.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
}

.app-container.sidebar-collapsed .logo-text,
.app-container.sidebar-collapsed .nav-label,
.app-container.sidebar-collapsed .nav-section-title {
    display: none;
}

.app-container.sidebar-collapsed .nav-item {
    justify-content: center;
    gap: 0;
    padding: 0.75rem 0.5rem;
}

.app-container.sidebar-collapsed .nav-icon {
    width: auto;
}

/* Ensure the collapse/expand button remains visible when collapsed */
.app-container.sidebar-collapsed .sidebar-header {
    padding: 1rem 0.5rem;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

/* Navigation Groups and Submenus */
.nav-group .nav-item {
    justify-content: space-between;
}

.nav-arrow {
    font-size: 0.8rem;
    transition: transform 0.2s ease;
}

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

.nav-submenu {
    display: none;
    background: rgba(0, 0, 0, 0.2);
    padding-left: 2rem;
}

.nav-group.expanded .nav-submenu {
    display: block;
}

.nav-subitem {
    display: flex;
    align-items: center;
    padding: 0.5rem 1.5rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.nav-subitem:hover {
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.9);
}

.nav-subitem.active {
    background: rgba(0, 178, 204, 0.15);
    color: var(--primary-cyan);
}

/* Breadcrumb Navigation */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.breadcrumb-item {
    background: none;
    border: none;
    color: var(--primary-cyan);
    cursor: pointer;
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.breadcrumb-item:hover {
    background: rgba(0, 178, 204, 0.1);
}

.breadcrumb-separator {
    color: var(--text-gray);
}

.breadcrumb-current {
    color: var(--text-gray);
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary-cyan);
    cursor: pointer;
    text-decoration: underline;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    /* Use fixed viewport height and hide outer scroll to avoid double scrollbars */
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.app-container.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* Header */
.main-header {
    background: white;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sidebar-toggle {
    display: inline-flex;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-gray);
}

/* Improve toggle appearance when placed in sidebar */
.sidebar .sidebar-toggle {
    color: rgba(255, 255, 255, 0.85);
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.sidebar .sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.12);
}

/* Chevron icon animation */
.sidebar .sidebar-toggle svg {
    transition: transform 0.2s ease;
}

/* Header toggle chevron animation + collapsed flip */
#headerSidebarToggle svg { transition: transform 0.2s ease; }
.app-container.sidebar-collapsed #headerSidebarToggle svg { transform: rotate(180deg); }

/* When collapsed, flip chevron to point right (expand) */
.app-container.sidebar-collapsed .sidebar .sidebar-toggle svg {
    transform: rotate(180deg);
}

.search-bar {
    display: flex;
    align-items: center;
    background: var(--primary-silver);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    gap: 0.5rem;
    min-width: 300px;
    position: relative;
}

.search-bar input {
    background: transparent;
    border: none;
    outline: none;
    flex: 1;
}

.search-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-gray);
}

/* Clear (x) button inside global search */
.search-clear {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-gray);
    display: none; /* shown when input has value */
    font-size: 16px;
    line-height: 1;
}
.search-clear:hover { color: var(--primary-dark); }

.search-results {
    position: absolute;
    top: calc(100% + 0.25rem);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: none;
    max-height: 300px;
    overflow-y: auto;
}

.search-section {
    border-bottom: 1px solid var(--border-color);
}

.search-section:last-child {
    border-bottom: none;
}

.search-title {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-gray);
}

.search-item {
    padding: 0.5rem 1rem;
    cursor: pointer;
}

.search-item:hover {
    background: var(--primary-silver);
}

.search-item.active {
    background: var(--primary-silver);
}

.search-empty {
    padding: 0.5rem 1rem;
    color: var(--text-gray);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Spacing for quick log time button moved from inline */
#quickLogTimeBtn { margin-right: 8px; }

.header-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    color: var(--text-gray);
    position: relative;
    padding: 0.5rem;
    border-radius: 8px;
    transition: background-color 0.2s ease;
}

.header-btn:hover {
    background: var(--primary-silver);
}

.notification-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--danger);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.125rem 0.375rem;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    z-index: 1;
}

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

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-cyan);
    color: white !important;
    border: 2px solid white;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    text-transform: uppercase;
}

.user-avatar:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

/* Page Container */
.page-container {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

/* Footer */
.app-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50; /* Below sidebar (z-index: 100) */
    background: #ffffff;
    border-top: 1px solid var(--border-color);
    padding: 0.5rem 1.25rem;
    color: var(--text-gray);
    font-size: 0.75rem; /* Smaller text */
}

.app-footer .footer-content {
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    .app-footer {
        padding: 0.5rem 0.75rem;
        font-size: 0.7rem;
        text-align: center;
    }
}

/* Ensure page content isn't hidden behind fixed footer */
.page-container {
    padding-bottom: 3.25rem; /* Space for footer */
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--primary-dark);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.5s ease;
}

.loading-screen.hidden {
    display: flex;
    opacity: 0;
    pointer-events: none;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid var(--primary-cyan);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-screen p {
    color: white;
    font-size: 1.125rem;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .sidebar-toggle { display: inline-flex; }
    .search-bar { min-width: 200px; }
}

@media (max-width: 768px) {
    .main-header {
        padding: 1rem;
    }
    
    .page-container {
        padding: 1rem;
    }
    
    .search-bar {
        min-width: 150px;
    }
    
    .header-left {
        gap: 0.5rem;
    }
}

/* Hide sidebar's toggle on tablet/mobile (we use floating mobile button) */
@media (max-width: 1024px) {
    .sidebar .sidebar-toggle { display: none !important; }
}

/* Hide header sidebar toggle on mobile/tablet (use mobile hamburger) */
@media (max-width: 1024px) {
    #headerSidebarToggle { display: none !important; }
}

/* Login Page Styles */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-cyan) 100%);
    padding: 2rem;
}

.login-card {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    max-width: 400px;
    width: 100%;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header .logo {
    justify-content: center;
    margin-bottom: 1rem;
}

.login-header p {
    color: var(--text-gray);
    font-size: 0.875rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
