/* =============================================
   DESIGN SYSTEM — Quản Lý Tài Sản v1.0
   CĐ Đắk Lắk | Font: Inter | Theme: Project OS
   Sidebar tối + Content sáng + Gradient accent cards
   ============================================= */

/* ---------- CSS Variables (Design Tokens) ---------- */
:root {
    /* Colors — Content Area (Light) */
    --color-bg-primary: #f0f2f5;
    --color-bg-secondary: #ffffff;
    --color-bg-tertiary: #e8ecf1;
    --color-bg-card: #ffffff;
    --color-bg-glass: rgba(255, 255, 255, 0.85);
    --color-bg-hover: rgba(99, 102, 241, 0.06);
    --color-bg-input: #ffffff;

    /* Sidebar Dark */
    --sidebar-bg: #0f172a;
    --sidebar-bg-hover: rgba(255, 255, 255, 0.06);
    --sidebar-bg-active: rgba(99, 102, 241, 0.15);
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    --sidebar-border: rgba(255, 255, 255, 0.06);
    --sidebar-accent: #6366f1;

    /* Accent Colors — Indigo/Violet */
    --color-primary: #6366f1;
    --color-primary-hover: #4f46e5;
    --color-primary-light: rgba(99, 102, 241, 0.12);
    --color-secondary: #8b5cf6;
    --color-secondary-light: rgba(139, 92, 246, 0.12);

    /* Status Colors */
    --color-success: #10b981;
    --color-success-light: rgba(16, 185, 129, 0.12);
    --color-warning: #f59e0b;
    --color-warning-light: rgba(245, 158, 11, 0.12);
    --color-danger: #ef4444;
    --color-danger-light: rgba(239, 68, 68, 0.12);
    --color-info: #06b6d4;
    --color-info-light: rgba(6, 182, 212, 0.12);

    /* Text */
    --color-text-primary: #1e293b;
    --color-text-secondary: #475569;
    --color-text-muted: #94a3b8;
    --color-text-inverse: #ffffff;

    /* Borders */
    --color-border: #e2e8f0;
    --color-border-hover: #cbd5e1;
    --color-border-focus: var(--color-primary);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 24px rgba(99, 102, 241, 0.35);
    --shadow-card: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.02);

    /* 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;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 20px;
    --radius-full: 9999px;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.8125rem;
    --font-size-base: 0.9375rem;
    --font-size-lg: 1.0625rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    --font-size-4xl: 2.25rem;

    /* Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;
    --header-height: 60px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Z-index */
    --z-sidebar: 40;
    --z-header: 30;
    --z-modal: 50;
    --z-toast: 60;
    --z-tooltip: 70;

    /* Stat Card Gradients */
    --gradient-coral: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    --gradient-mint: linear-gradient(135deg, #0abde3 0%, #10ac84 100%);
    --gradient-lavender: linear-gradient(135deg, #a29bfe 0%, #6c5ce7 100%);
    --gradient-amber: linear-gradient(135deg, #feca57 0%, #ff9f43 100%);
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: 400;
    line-height: 1.6;
    color: var(--color-text-primary);
    background-color: var(--color-bg-primary);
    overflow: hidden;
}

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

a:hover { color: var(--color-primary-hover); }

img { max-width: 100%; height: auto; display: block; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }

/* ---------- App Layout ---------- */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* ---------- Sidebar — Dark Navy Theme ---------- */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    z-index: var(--z-sidebar);
    transition: width var(--transition-base), transform var(--transition-base);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-logo {
    padding: var(--space-5) var(--space-5);
    border-bottom: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-height: var(--header-height);
}

.sidebar-logo h1 {
    font-size: var(--font-size-base);
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
    letter-spacing: -0.02em;
}

.sidebar-nav {
    flex: 1;
    padding: var(--space-3) var(--space-3);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-section-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(148, 163, 184, 0.5);
    padding: var(--space-5) var(--space-3) var(--space-2);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    color: var(--sidebar-text);
    font-size: var(--font-size-sm);
    font-weight: 450;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    position: relative;
}

.nav-item:hover {
    background: var(--sidebar-bg-hover);
    color: var(--sidebar-text-active);
}

.nav-item.active {
    background: var(--sidebar-bg-active);
    color: var(--sidebar-text-active);
}

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

.nav-item .badge {
    margin-left: auto;
    background: var(--color-danger);
    color: white;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: var(--radius-full);
    min-width: 18px;
    text-align: center;
}

/* ---------- Main Content ---------- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    transition: margin-left var(--transition-base);
}

/* ---------- Header — Clean White ---------- */
.header {
    height: var(--header-height);
    min-height: var(--header-height);
    background: var(--color-bg-secondary);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-6);
    z-index: var(--z-header);
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.header-title {
    font-size: var(--font-size-xl);
    font-weight: 700;
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

/* ---------- Page Content ---------- */
.page-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-6);
}

/* ---------- Cards — Clean White + Subtle Shadow ---------- */
.card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    box-shadow: var(--shadow-card);
    transition: all var(--transition-base);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

/* ---------- Stat Cards — Gradient Style ---------- */
.stat-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.stat-card {
    border-radius: var(--radius-xl);
    padding: var(--space-5) var(--space-5);
    color: white;
    position: relative;
    overflow: hidden;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    border: none;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-card.coral { background: var(--gradient-coral); }
.stat-card.mint { background: var(--gradient-mint); }
.stat-card.lavender { background: var(--gradient-lavender); }
.stat-card.amber { background: var(--gradient-amber); }

.stat-card::after {
    content: '';
    position: absolute;
    right: -20px;
    bottom: -20px;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
}

.stat-card .stat-label {
    font-size: var(--font-size-sm);
    font-weight: 500;
    opacity: 0.9;
    margin-bottom: var(--space-2);
}

.stat-card .stat-value {
    font-size: var(--font-size-3xl);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1;
}

.stat-card .stat-icon {
    position: absolute;
    right: var(--space-5);
    top: var(--space-5);
    opacity: 0.3;
}

.card:hover {
    border-color: var(--color-border-hover);
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
}

.card-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
}

/* ---------- Stats Cards ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.stat-card {
    background: var(--color-bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    display: flex;
    align-items: center;
    gap: var(--space-4);
    transition: all var(--transition-base);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--color-border-hover);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.blue   { background: var(--color-primary-light); color: var(--color-primary); }
.stat-icon.green  { background: var(--color-success-light); color: var(--color-success); }
.stat-icon.yellow { background: var(--color-warning-light); color: var(--color-warning); }
.stat-icon.red    { background: var(--color-danger-light);  color: var(--color-danger); }
.stat-icon.purple { background: var(--color-secondary-light); color: var(--color-secondary); }
.stat-icon.cyan   { background: var(--color-info-light);    color: var(--color-info); }

.stat-info { flex: 1; }

.stat-value {
    font-size: var(--font-size-2xl);
    font-weight: 800;
    line-height: 1.2;
}

.stat-label {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    font-weight: 500;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    line-height: 1.5;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-hover));
    color: white;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
}
.btn-primary:hover {
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.5);
    transform: translateY(-1px);
}

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

.btn-danger {
    background: linear-gradient(135deg, var(--color-danger), #dc2626);
    color: white;
}
.btn-danger:hover { box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4); }

.btn-success {
    background: linear-gradient(135deg, var(--color-success), #059669);
    color: white;
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-secondary);
    border: none;
}
.btn-ghost:hover { color: var(--color-text-primary); background: var(--color-bg-hover); }

.btn-sm { padding: var(--space-1) var(--space-3); font-size: var(--font-size-xs); }
.btn-lg { padding: var(--space-3) var(--space-6); font-size: var(--font-size-base); }
.btn-icon { padding: var(--space-2); width: 36px; height: 36px; }

/* ---------- Form Inputs ---------- */
.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.form-label {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text-secondary);
}

.form-label .required { color: var(--color-danger); margin-left: 2px; }

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    color: var(--color-text-primary);
    background: var(--color-bg-input);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    outline: none;
    transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--color-border-focus);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.form-input::placeholder { color: var(--color-text-muted); }

.form-textarea { min-height: 100px; resize: vertical; }

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* ---------- Badges / Status ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.badge-active     { background: var(--color-success-light); color: var(--color-success); }
.badge-in-use     { background: var(--color-primary-light); color: var(--color-primary); }
.badge-maintenance{ background: var(--color-warning-light); color: var(--color-warning); }
.badge-broken     { background: var(--color-danger-light);  color: var(--color-danger); }
.badge-disposed   { background: rgba(100,116,139,0.15);     color: var(--color-text-muted); }
.badge-pending    { background: var(--color-info-light);     color: var(--color-info); }
.badge-approved   { background: var(--color-success-light); color: var(--color-success); }
.badge-rejected   { background: var(--color-danger-light);  color: var(--color-danger); }
.badge-overdue    { background: var(--color-danger-light);  color: var(--color-danger); }

/* ---------- Loading ---------- */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 60vh;
    gap: var(--space-4);
    color: var(--color-text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-bg-tertiary);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center;
    padding: var(--space-12) var(--space-6);
    color: var(--color-text-muted);
}

.empty-state i { font-size: 48px; margin-bottom: var(--space-4); opacity: 0.5; }
.empty-state h3 { font-size: var(--font-size-lg); color: var(--color-text-secondary); margin-bottom: var(--space-2); }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }
    .sidebar.open { transform: translateX(0); }

    .main-content { margin-left: 0; }

    .page-content { padding: var(--space-4); }

    .stats-grid { grid-template-columns: repeat(2, 1fr); }

    .header-title { font-size: var(--font-size-base); }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
}

/* ---------- Utilities ---------- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.text-sm { font-size: var(--font-size-sm); }
.text-muted { color: var(--color-text-secondary); }
.text-center { text-align: center; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }

/* ---------- Animations ---------- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideInUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse { 50% { opacity: 0.5; } }

.animate-fade-in   { animation: fadeIn 0.3s ease forwards; }
.animate-slide-up  { animation: slideInUp 0.3s ease forwards; }
.animate-slide-left{ animation: slideInLeft 0.3s ease forwards; }
