/**
 * Construction ERP - Design System
 * Modern Material Design with Dark/Light Theme Support
 */

/* =====================================================
   CSS VARIABLES / DESIGN TOKENS
   ===================================================== */

:root {
    /* Primary Colors */
    --primary-50: #e3f2fd;
    --primary-100: #bbdefb;
    --primary-200: #90caf9;
    --primary-300: #64b5f6;
    --primary-400: #42a5f5;
    --primary-500: #2196f3;
    --primary-600: #1e88e5;
    --primary-700: #1976d2;
    --primary-800: #1565c0;
    --primary-900: #0d47a1;

    /* Secondary Colors - Construction Orange */
    --secondary-50: #fff3e0;
    --secondary-100: #ffe0b2;
    --secondary-200: #ffcc80;
    --secondary-300: #ffb74d;
    --secondary-400: #ffa726;
    --secondary-500: #ff9800;
    --secondary-600: #fb8c00;
    --secondary-700: #f57c00;
    --secondary-800: #ef6c00;
    --secondary-900: #e65100;

    /* Success Colors */
    --success-50: #e8f5e9;
    --success-500: #4caf50;
    --success-700: #388e3c;

    /* Warning Colors */
    --warning-50: #fff8e1;
    --warning-500: #ffc107;
    --warning-700: #ffa000;

    /* Error Colors */
    --error-50: #ffebee;
    --error-500: #f44336;
    --error-700: #d32f2f;

    /* Neutral Colors */
    --gray-50: #fafafa;
    --gray-100: #f5f5f5;
    --gray-200: #eeeeee;
    --gray-300: #e0e0e0;
    --gray-400: #bdbdbd;
    --gray-500: #9e9e9e;
    --gray-600: #757575;
    --gray-700: #616161;
    --gray-800: #424242;
    --gray-900: #212121;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;

    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    --radius-xl: 0.75rem;
    --radius-2xl: 1rem;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;

    /* Z-Index */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
    --z-toast: 1080;

    /* Layout */
    --sidebar-width: 260px;
    --header-height: 64px;
    --content-max-width: 1400px;
}

/* Light Theme (Default) */
[data-theme="light"],
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-elevated: #ffffff;
    --bg-hover: rgba(0, 0, 0, 0.04);
    --bg-active: rgba(0, 0, 0, 0.08);

    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;
    --text-inverse: #ffffff;

    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --divider: #e2e8f0;

    --input-bg: #ffffff;
    --input-border: #cbd5e1;
    --input-focus-border: var(--primary-500);
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-elevated: #1e293b;
    --bg-hover: rgba(255, 255, 255, 0.05);
    --bg-active: rgba(255, 255, 255, 0.1);

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;
    --text-inverse: #0f172a;

    --border-color: #334155;
    --border-light: #1e293b;
    --divider: #334155;

    --input-bg: #1e293b;
    --input-border: #475569;
    --input-focus-border: var(--primary-400);

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
}

/* =====================================================
   BASE STYLES
   ===================================================== */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    min-height: 100vh;
}

a {
    color: var(--primary-600);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-700);
}

/* =====================================================
   LAYOUT
   ===================================================== */

.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: var(--z-fixed);
    transition: width var(--transition-normal), transform var(--transition-normal);
    overflow: hidden;
}

/* Sidebar Collapsed State */
.sidebar.collapsed {
    width: 72px;
}

.sidebar.collapsed .sidebar-brand,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .sidebar-collapse-text {
    opacity: 0;
    visibility: hidden;
    width: 0;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: var(--space-4) var(--space-2);
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: var(--space-3);
}

.sidebar.collapsed .nav-icon {
    margin: 0;
}

.sidebar.collapsed .sidebar-collapse-btn svg {
    transform: rotate(180deg);
}

/* Sidebar Header */
.sidebar-header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-height: 65px;
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    min-width: 40px;
    background: linear-gradient(135deg, var(--primary-500), var(--secondary-500));
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: var(--text-lg);
    transition: transform var(--transition-fast);
}

.sidebar-logo:hover {
    transform: scale(1.05);
}

.sidebar-brand {
    font-weight: 600;
    font-size: var(--text-lg);
    color: var(--text-primary);
    transition: opacity var(--transition-fast), width var(--transition-fast);
}

.sidebar-nav {
    flex: 1;
    padding: var(--space-4);
    overflow-y: auto;
    overflow-x: hidden;
}

/* Custom scrollbar for sidebar */
.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-full);
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

.nav-section {
    margin-bottom: var(--space-6);
}

.nav-section-title {
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    padding: var(--space-2) var(--space-3);
    margin-bottom: var(--space-1);
    transition: opacity var(--transition-fast);
    white-space: nowrap;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-3);
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    font-weight: 500;
    transition: all var(--transition-fast);
    margin-bottom: var(--space-1);
    position: relative;
    overflow: hidden;
    white-space: nowrap;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: var(--primary-500);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    transition: height var(--transition-fast);
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    transform: translateX(2px);
}

.nav-item:hover::before {
    height: 60%;
}

.nav-item.active {
    background: var(--primary-50);
    color: var(--primary-700);
}

.nav-item.active::before {
    height: 100%;
}

[data-theme="dark"] .nav-item.active {
    background: rgba(33, 150, 243, 0.15);
    color: var(--primary-400);
}

.nav-icon {
    width: 20px;
    height: 20px;
    min-width: 20px;
    opacity: 0.8;
    transition: transform var(--transition-fast);
}

.nav-item:hover .nav-icon {
    transform: scale(1.1);
}

.nav-item span {
    transition: opacity var(--transition-fast), width var(--transition-fast);
}

.nav-badge {
    margin-left: auto;
    background: var(--error-500);
    color: white;
    font-size: var(--text-xs);
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

/* Sidebar Footer with Collapse Button */
.sidebar-footer {
    padding: var(--space-3);
    border-top: 1px solid var(--border-color);
}

.sidebar-collapse-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    padding: var(--space-3);
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.sidebar-collapse-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-collapse-btn svg {
    transition: transform var(--transition-normal);
}

.sidebar-collapse-text {
    transition: opacity var(--transition-fast), width var(--transition-fast);
}

/* Mobile Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: calc(var(--z-fixed) - 1);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Main Content Area */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--transition-normal);
}

.sidebar.collapsed~.main-content {
    margin-left: 72px;
}

/* Header */
.header {
    height: var(--header-height);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-6);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.header-title {
    font-size: var(--text-xl);
    font-weight: 600;
    color: var(--text-primary);
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.breadcrumb-separator {
    color: var(--text-tertiary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.header-search {
    position: relative;
    width: 280px;
}

.header-search input {
    width: 100%;
    padding: var(--space-2) var(--space-4) var(--space-2) var(--space-10);
    background: var(--bg-tertiary);
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.header-search input:focus {
    outline: none;
    background: var(--bg-primary);
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.header-search-icon {
    position: absolute;
    left: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    width: 18px;
    height: 18px;
}

/* Icon Buttons */
.icon-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.icon-btn .badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    background: var(--error-500);
    border-radius: 50%;
}

/* User Avatar */
.user-menu {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.user-menu:hover {
    background: var(--bg-hover);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary-400), var(--primary-600));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: var(--text-sm);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 500;
    font-size: var(--text-sm);
    color: var(--text-primary);
}

.user-role {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

/* Page Content */
.page-content {
    flex: 1;
    padding: var(--space-6);
    max-width: var(--content-max-width);
    width: 100%;
    margin: 0 auto;
}

/* =====================================================
   COMPONENTS
   ===================================================== */

/* Cards */
.card {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    padding: var(--space-5);
}

.card-footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

/* Stat Cards */
.stat-card {
    padding: var(--space-5);
}

.stat-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-3);
}

.stat-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-card-icon.primary {
    background: rgba(33, 150, 243, 0.1);
    color: var(--primary-600);
}

.stat-card-icon.success {
    background: rgba(76, 175, 80, 0.1);
    color: var(--success-500);
}

.stat-card-icon.warning {
    background: rgba(255, 152, 0, 0.1);
    color: var(--secondary-600);
}

.stat-card-icon.error {
    background: rgba(244, 67, 54, 0.1);
    color: var(--error-500);
}

.stat-value {
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-top: var(--space-1);
}

.stat-change {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-size: var(--text-sm);
    font-weight: 500;
    margin-top: var(--space-2);
}

.stat-change.positive {
    color: var(--success-500);
}

.stat-change.negative {
    color: var(--error-500);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
    font-weight: 500;
    border-radius: var(--radius-lg);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary-600);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-700);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-active);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--text-tertiary);
}

.btn-danger {
    background: var(--error-500);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: var(--error-700);
}

.btn-success {
    background: var(--success-500);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: var(--success-700);
}

.btn-lg {
    padding: var(--space-3) var(--space-6);
    font-size: var(--text-base);
}

.btn-sm {
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
}

/* Forms */
.form-group {
    margin-bottom: var(--space-4);
}

.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.form-label.required::after {
    content: '*';
    color: var(--error-500);
    margin-left: var(--space-1);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--input-focus-border);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.form-input::placeholder {
    color: var(--text-tertiary);
}

.form-input.error {
    border-color: var(--error-500);
}

.form-error {
    color: var(--error-500);
    font-size: var(--text-xs);
    margin-top: var(--space-1);
}

.form-help {
    color: var(--text-tertiary);
    font-size: var(--text-xs);
    margin-top: var(--space-1);
}

/* Tables */
.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    background: var(--bg-secondary);
}

.table tbody tr {
    transition: background var(--transition-fast);
}

.table tbody tr:hover {
    background: var(--bg-hover);
}

.table td {
    font-size: var(--text-sm);
    color: var(--text-primary);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-xs);
    font-weight: 500;
    border-radius: var(--radius-md);
}

.badge-success {
    background: var(--success-50);
    color: var(--success-700);
}

.badge-warning {
    background: var(--warning-50);
    color: var(--warning-700);
}

.badge-error {
    background: var(--error-50);
    color: var(--error-700);
}

.badge-primary {
    background: var(--primary-50);
    color: var(--primary-700);
}

.badge-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

/* Progress Bar */
.progress {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--primary-500);
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

.progress-bar.success {
    background: var(--success-500);
}

.progress-bar.warning {
    background: var(--warning-500);
}

.progress-bar.error {
    background: var(--error-500);
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--z-modal-backdrop);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    z-index: var(--z-modal);
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.modal-header {
    padding: var(--space-5);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: var(--text-lg);
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: var(--space-2);
    margin: calc(-1 * var(--space-2));
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: var(--space-5);
    overflow-y: auto;
    max-height: calc(90vh - 140px);
}

.modal-footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.toast {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--space-4);
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    min-width: 320px;
    max-width: 400px;
    animation: slideIn var(--transition-normal);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    margin-bottom: var(--space-1);
}

.toast-message {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.toast.success .toast-icon {
    color: var(--success-500);
}

.toast.error .toast-icon {
    color: var(--error-500);
}

.toast.warning .toast-icon {
    color: var(--warning-500);
}

/* =====================================================
   GRID & UTILITIES
   ===================================================== */

.grid {
    display: grid;
    gap: var(--space-6);
}

.grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.items-start {
    align-items: flex-start;
}

.justify-between {
    justify-content: space-between;
}

.justify-center {
    justify-content: center;
}

.gap-2 {
    gap: var(--space-2);
}

.gap-3 {
    gap: var(--space-3);
}

.gap-4 {
    gap: var(--space-4);
}

.gap-6 {
    gap: var(--space-6);
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.font-bold {
    font-weight: 700;
}

.font-medium {
    font-weight: 500;
}

.text-sm {
    font-size: var(--text-sm);
}

.text-xs {
    font-size: var(--text-xs);
}

.text-lg {
    font-size: var(--text-lg);
}

.text-muted {
    color: var(--text-secondary);
}

.mt-2 {
    margin-top: var(--space-2);
}

.mt-4 {
    margin-top: var(--space-4);
}

.mt-6 {
    margin-top: var(--space-6);
}

.mb-2 {
    margin-bottom: var(--space-2);
}

.mb-4 {
    margin-bottom: var(--space-4);
}

.mb-6 {
    margin-bottom: var(--space-6);
}

.hidden {
    display: none;
}

/* =====================================================
   USER DROPDOWN MENU
   ===================================================== */

.user-menu {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: background var(--transition-fast);
    position: relative;
}

.user-menu:hover {
    background: var(--bg-hover);
}

.user-menu>.user-name {
    font-weight: 500;
    font-size: var(--text-sm);
    color: var(--text-primary);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + var(--space-2));
    right: 0;
    min-width: 240px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-fast);
    z-index: var(--z-dropdown);
    overflow: hidden;
}

.user-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.dropdown-header strong {
    display: block;
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--text-primary);
}

.dropdown-header span {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: var(--space-1) 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-weight: 500;
    transition: all var(--transition-fast);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    text-decoration: none;
}

.dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--primary-600);
}

.dropdown-item svg {
    width: 16px;
    height: 16px;
    opacity: 0.7;
    flex-shrink: 0;
}

.dropdown-item.logout-btn {
    color: var(--error-500);
}

.dropdown-item.logout-btn:hover {
    background: var(--error-50);
    color: var(--error-700);
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.mobile-menu-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* =====================================================
   RESPONSIVE
   ===================================================== */

/* Large Desktop */
@media (min-width: 1400px) {
    .page-content {
        padding: var(--space-8);
    }
}

/* Tablet Landscape / Small Desktop */
@media (max-width: 1200px) {
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .header-search {
        width: 200px;
    }
}

/* Tablet Portrait */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 72px;
    }

    .sidebar {
        width: 72px;
    }

    .sidebar .sidebar-brand,
    .sidebar .nav-section-title,
    .sidebar .nav-item span,
    .sidebar .sidebar-collapse-text {
        opacity: 0;
        visibility: hidden;
        width: 0;
    }

    .sidebar .sidebar-header {
        justify-content: center;
        padding: var(--space-4) var(--space-2);
    }

    .sidebar .nav-item {
        justify-content: center;
        padding: var(--space-3);
    }

    .sidebar .sidebar-footer {
        display: none;
    }

    /* Expand sidebar on hover for tablet */
    .sidebar:hover {
        width: 260px;
    }

    .sidebar:hover .sidebar-brand,
    .sidebar:hover .nav-section-title,
    .sidebar:hover .nav-item span {
        opacity: 1;
        visibility: visible;
        width: auto;
    }

    .sidebar:hover .sidebar-header {
        justify-content: flex-start;
        padding: var(--space-4) var(--space-5);
    }

    .sidebar:hover .nav-item {
        justify-content: flex-start;
        padding: var(--space-3) var(--space-3);
    }

    .main-content {
        margin-left: 72px;
    }

    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-cols-3 {
        grid-template-columns: repeat(2, 1fr);
    }

    .header-search {
        width: 180px;
    }

    .user-info {
        display: none;
    }
}

/* Mobile */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 280px;
    }

    .sidebar {
        width: var(--sidebar-width);
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    /* Reset hover expand for mobile */
    .sidebar:hover {
        width: var(--sidebar-width);
    }

    .sidebar .sidebar-brand,
    .sidebar .nav-section-title,
    .sidebar .nav-item span,
    .sidebar .sidebar-collapse-text,
    .sidebar:hover .sidebar-brand,
    .sidebar:hover .nav-section-title,
    .sidebar:hover .nav-item span {
        opacity: 1;
        visibility: visible;
        width: auto;
    }

    .sidebar .sidebar-header,
    .sidebar:hover .sidebar-header {
        justify-content: flex-start;
        padding: var(--space-4) var(--space-5);
    }

    .sidebar .nav-item,
    .sidebar:hover .nav-item {
        justify-content: flex-start;
        padding: var(--space-3) var(--space-3);
    }

    .sidebar .sidebar-footer {
        display: none;
    }

    .sidebar-overlay {
        display: none;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: 1fr;
    }

    .header-search {
        display: none;
    }

    .header-title {
        font-size: var(--text-lg);
    }

    .page-content {
        padding: var(--space-4);
    }

    .header {
        padding: 0 var(--space-4);
    }

    .card-header,
    .card-body {
        padding: var(--space-4);
    }

    .table th,
    .table td {
        padding: var(--space-2) var(--space-3);
        font-size: var(--text-xs);
    }

    .btn {
        padding: var(--space-2) var(--space-3);
        font-size: var(--text-xs);
    }

    .stat-card {
        padding: var(--space-4);
    }

    .stat-value {
        font-size: var(--text-2xl);
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .header-right {
        gap: var(--space-2);
    }

    .icon-btn {
        width: 36px;
        height: 36px;
    }

    .user-avatar {
        width: 32px;
        height: 32px;
    }

    .page-content {
        padding: var(--space-3);
    }

    .modal {
        width: calc(100% - var(--space-4));
        max-height: calc(100vh - var(--space-8));
        margin: var(--space-4) auto;
    }
}

/* =====================================================
   ANIMATIONS
   ===================================================== */

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-slide-in {
    animation: slideIn var(--transition-normal) ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.animate-fade-in {
    animation: fadeIn var(--transition-normal) ease-out;
}

/* Loading Skeleton */
.skeleton {
    background: linear-gradient(90deg,
            var(--bg-tertiary) 25%,
            var(--bg-secondary) 50%,
            var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: var(--radius-md);
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* =====================================================
   ENHANCED LAYOUT COMPONENTS
   ===================================================== */

/* Sidebar Toggle Button */
.sidebar-toggle-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.sidebar-toggle-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar.collapsed .sidebar-toggle-btn svg {
    transform: rotate(180deg);
}

/* Header Icon Buttons */
.header-icon-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.header-icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.notification-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--error-500);
    border-radius: 50%;
}

/* Sidebar Mobile Open State */
.sidebar.mobile-open {
    transform: translateX(0) !important;
}


/* =====================================================
   RESPONSIVE OVERRIDES
   ===================================================== */

@media (max-width: 1024px) {

    .sidebar.collapsed~.sidebar-overlay~.main-content,
    .sidebar.collapsed~.main-content {
        margin-left: 72px;
    }
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }

    .sidebar.collapsed~.sidebar-overlay~.main-content,
    .sidebar.collapsed~.main-content,
    .main-content {
        margin-left: 0;
    }

    .header-search {
        display: none;
    }

    .user-menu .user-name {
        display: none;
    }

    .header {
        padding: 0 var(--space-4);
    }

    .header-title {
        font-size: var(--text-lg);
    }
}

@media (max-width: 480px) {
    .header-right {
        gap: var(--space-2);
    }

    .header-icon-btn {
        width: 36px;
        height: 36px;
    }

    .user-avatar {
        width: 32px;
        height: 32px;
    }
}

/* =====================================================
   UPDATE SYSTEM STYLES
   ===================================================== */

/* Update Toast Notification */
.update-toast {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    padding: var(--space-5);
    width: 380px;
    max-width: calc(100vw - 48px);
    z-index: 9998;
    transform: translateY(120%);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.update-toast.visible {
    transform: translateY(0);
    opacity: 1;
}

/* Toast Header - Icon + Title + Badge */
.update-toast-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.update-toast-icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--primary-500), var(--secondary-500));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.update-toast-icon svg {
    width: 22px;
    height: 22px;
}

.update-toast-title-wrap {
    flex: 1;
}

.update-toast-title {
    font-weight: 600;
    font-size: var(--text-base);
    color: var(--text-primary);
    margin: 0;
    line-height: 1.3;
}

.update-version-badge {
    display: inline-block;
    font-size: var(--text-xs);
    font-weight: 600;
    padding: 3px 10px;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: white;
    border-radius: var(--radius-full);
    margin-top: var(--space-1);
}

[data-theme="dark"] .update-version-badge {
    background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
}

/* Toast Message */
.update-toast-message {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: var(--space-4);
    padding-left: calc(44px + var(--space-3));
}

/* Toast Actions */
.update-toast-actions {
    display: flex;
    gap: var(--space-2);
    justify-content: flex-end;
}

.update-toast-close {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    color: var(--text-tertiary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    margin-left: auto;
}

.update-toast-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* What's New Modal */
.whats-new-modal {
    max-width: 520px;
    width: 90%;
}

.changelog-section {
    margin-bottom: var(--space-5);
}

.changelog-section:last-child {
    margin-bottom: 0;
}

.changelog-section-title {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-3);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.changelog-icon {
    font-size: var(--text-lg);
}

.changelog-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.changelog-list li {
    position: relative;
    padding-left: var(--space-5);
    padding-bottom: var(--space-2);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.5;
}

.changelog-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary-500);
}

/* Force Update Modal */
.force-update-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.force-update-overlay.visible {
    opacity: 1;
}

.force-update-modal {
    background: var(--bg-primary);
    border-radius: var(--radius-2xl);
    padding: var(--space-8);
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-xl);
}

.force-update-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--warning-500), var(--error-500));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--space-5);
}

.force-update-modal h2 {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-3);
}

.force-update-modal p {
    color: var(--text-secondary);
    margin-bottom: var(--space-6);
    line-height: 1.5;
}

/* Update Badge */
.update-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary-500);
    border: 2px solid var(--bg-primary);
    animation: update-pulse 2s infinite;
}

@keyframes update-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(33, 150, 243, 0.4);
    }

    70% {
        box-shadow: 0 0 0 8px rgba(33, 150, 243, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(33, 150, 243, 0);
    }
}

/* Responsive Update Toast */
@media (max-width: 480px) {
    .update-toast {
        left: var(--space-4);
        right: var(--space-4);
        bottom: var(--space-4);
        max-width: none;
        flex-direction: column;
    }

    .update-toast-actions {
        width: 100%;
        flex-direction: column;
    }

    .update-toast-actions .btn {
        width: 100%;
    }
}

/* =====================================================
   PROJECT HEADER STYLES
   ===================================================== */

.project-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.project-header-info {
    flex: 1;
    min-width: 0;
    /* Allow text truncation */
}

.project-title {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 var(--space-1) 0;
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.project-header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.project-header-actions .form-select-sm {
    width: auto;
    min-width: 120px;
}

/* Mobile: Stack header vertically */
@media (max-width: 576px) {
    .project-header {
        flex-direction: column;
        gap: var(--space-3);
    }

    .project-title {
        font-size: var(--text-lg);
    }

    .project-header-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .project-header-actions .btn {
        flex: 1;
    }

    .project-header-actions .form-select-sm {
        flex: 1;
        min-width: 100px;
    }
}

/* =====================================================
   PWA INSTALL BANNER
   ===================================================== */

.pwa-install-banner {
    position: fixed;
    bottom: var(--space-6);
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    padding: var(--space-4) var(--space-5);
    display: flex;
    align-items: center;
    gap: var(--space-4);
    max-width: 500px;
    width: calc(100% - 48px);
    z-index: 9999;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.pwa-install-banner.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.pwa-install-icon {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    border-radius: var(--radius-xl);
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pwa-install-content {
    flex: 1;
    min-width: 0;
}

.pwa-install-title {
    font-weight: 600;
    font-size: var(--text-base);
    color: var(--text-primary);
    margin-bottom: 2px;
}

.pwa-install-message {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.pwa-install-actions {
    display: flex;
    gap: var(--space-2);
    flex-shrink: 0;
}

.pwa-install-close {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    color: var(--text-tertiary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.pwa-install-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Mobile PWA Banner */
@media (max-width: 576px) {
    .pwa-install-banner {
        flex-direction: column;
        text-align: center;
        padding: var(--space-5);
    }

    .pwa-install-actions {
        width: 100%;
    }

    .pwa-install-actions .btn {
        flex: 1;
    }
}

/* =====================================================
   NETWORK STATUS INDICATOR
   ===================================================== */

.network-status {
    position: fixed;
    top: var(--space-4);
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    background: #1e293b;
    color: white;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.network-status.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.network-status.offline {
    background: #f97316;
}

.network-status.online {
    background: #22c55e;
}