/* ============================================
   IMS - Custom Stylesheet
   ============================================ */

:root {
    --sidebar-width: 260px;
    --sidebar-bg: #1e2a3a;
    --sidebar-hover: #2d3f55;
    --sidebar-active: #3b82f6;
    --topbar-height: 60px;
    --primary: #3b82f6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #f1f5f9;
    color: #334155;
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    height: 100vh;
    position: fixed;
    top: 0; left: 0;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s ease;
    overflow: hidden;
}

.sidebar.collapsed {
    transform: translateX(calc(-1 * var(--sidebar-width)));
}

.sidebar-brand {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
}

.sidebar-brand a {
    display: flex;
    align-items: center;
    line-height: 1;
    outline: none;
}

.sidebar-brand svg { display: block; max-width: 100%; }

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }

.nav-label {
    color: rgba(255,255,255,0.4);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    padding: 12px 24px 4px;
    text-transform: uppercase;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-nav .nav-link i {
    width: 18px;
    text-align: center;
    font-size: 0.95rem;
}

.sidebar-nav .nav-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
    border-left-color: var(--primary);
}

.sidebar-nav .nav-link.active {
    background: rgba(59,130,246,0.15);
    color: #fff;
    border-left-color: var(--primary);
    font-weight: 600;
}

/* ---- Collapsible nav groups ---- */
.nav-group { }

.nav-parent-row {
    display: flex;
    align-items: stretch;
}
.nav-parent-row .nav-link {
    flex: 1;
    min-width: 0;
}
.nav-toggle-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.35);
    padding: 0 14px 0 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: color 0.2s;
    flex-shrink: 0;
}
.nav-toggle-btn:hover { color: rgba(255,255,255,0.8); }

.nav-chevron {
    font-size: 0.6rem;
    transition: transform 0.22s ease;
}
.nav-group.open .nav-chevron { transform: rotate(90deg); }

.nav-children {
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.25s ease;
}
.nav-group.open .nav-children { max-height: 400px; }

.nav-child {
    padding-left: 3rem !important;
    font-size: 0.82rem !important;
    color: rgba(255,255,255,0.6) !important;
    border-left: 3px solid transparent;
}
.nav-child:hover {
    color: #fff !important;
    background: var(--sidebar-hover);
    border-left-color: rgba(255,255,255,0.2);
}
.nav-child.active {
    color: #fff !important;
    background: rgba(59,130,246,0.12);
    border-left-color: var(--primary);
    font-weight: 600 !important;
}
.nav-child i { font-size: 0.8rem !important; }

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.user-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

.user-details { min-width: 0; }

.user-name {
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 1px 6px;
    border-radius: 4px;
}

.badge-role-admin    { background: rgba(239,68,68,0.25); color: #fca5a5; }
.badge-role-manager  { background: rgba(245,158,11,0.25); color: #fcd34d; }
.badge-role-staff    { background: rgba(16,185,129,0.25); color: #6ee7b7; }

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

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

/* ---- Topbar ---- */
.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1e293b;
    flex: 1;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-toggle { padding: 4px 8px; color: #64748b !important; }

/* ---- Content Area ---- */
.content-area {
    padding: 24px;
    flex: 1;
}

/* ---- Stat Cards ---- */
.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    border: 1px solid #e2e8f0;
    transition: box-shadow 0.2s;
}

.stat-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); }

.stat-icon {
    width: 56px; height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-icon.blue   { background: #eff6ff; color: var(--primary); }
.stat-icon.green  { background: #f0fdf4; color: var(--success); }
.stat-icon.yellow { background: #fffbeb; color: var(--warning); }
.stat-icon.red    { background: #fef2f2; color: var(--danger); }

.stat-info { min-width: 0; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: #1e293b; line-height: 1; }
.stat-label { font-size: 0.82rem; color: #64748b; margin-top: 4px; }

/* ---- Cards ---- */
.card {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: none;
}

.card-header {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    border-radius: 12px 12px 0 0 !important;
    padding: 16px 20px;
    font-weight: 600;
    color: #1e293b;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ---- Tables ---- */
.table { margin-bottom: 0; }
.table thead th {
    background: #f8fafc;
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #e2e8f0;
    padding: 10px 16px;
}
.table tbody td { padding: 12px 16px; vertical-align: middle; font-size: 0.9rem; }
.table tbody tr:hover { background: #f8fafc; }

/* ---- Badges ---- */
.badge-status {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-active   { background: #dcfce7; color: #166534; }
.badge-inactive { background: #fee2e2; color: #991b1b; }
.badge-low      { background: #fef9c3; color: #854d0e; }

/* ---- Buttons ---- */
.btn-primary   { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: #2563eb; border-color: #2563eb; }

.btn-action {
    width: 32px; height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 0.8rem;
}

/* ---- Forms ---- */
.form-label { font-weight: 600; font-size: 0.85rem; color: #374151; margin-bottom: 4px; }
.form-control, .form-select {
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.9rem;
    padding: 8px 12px;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

/* ---- Login Page ---- */
.login-wrapper {
    min-height: 100vh;
    width: 100vw;
    background: linear-gradient(135deg, #1e2a3a 0%, #2d3f55 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-logo {
    width: 64px; height: 64px;
    background: linear-gradient(135deg, var(--primary), #1d4ed8);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.8rem;
    margin: 0 auto 20px;
}

/* ---- Quantity Badges ---- */
.qty-ok  { color: var(--success); font-weight: 700; }
.qty-low { color: var(--warning); font-weight: 700; }
.qty-out { color: var(--danger);  font-weight: 700; }

/* ---- Page Header ---- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.page-header h5 {
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}

/* ---- Transaction Type Badges ---- */
.badge-in  { background: #dcfce7; color: #166534; }
.badge-out { background: #fee2e2; color: #991b1b; }
.badge-adj { background: #e0f2fe; color: #0c4a6e; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .sidebar { transform: translateX(calc(-1 * var(--sidebar-width))); }
    .sidebar.mobile-open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .content-area { padding: 16px; }
    .topbar { padding: 0 16px; }
}

/* ---- Dark Mode ---- */
html.dark {
    color-scheme: dark;
}
html.dark body {
    background: #0f172a;
    color: #e2e8f0;
}
html.dark .sidebar      { background: #0d1826; }
html.dark .sidebar-hover { background: #1a2740; }
html.dark .topbar       { background: #1e293b; border-color: #334155; }
html.dark .topbar-title { color: #f1f5f9; }
html.dark .topbar .text-muted { color: #94a3b8 !important; }
html.dark .main-content { background: #0f172a; }

html.dark .card         { background: #1e293b; border-color: #334155; }
html.dark .card-header  { background: #1e293b; border-color: #334155; color: #f1f5f9; }
html.dark .card-body    { background: #1e293b; }

html.dark .table thead th    { background: #162032; color: #94a3b8; border-color: #334155; }
html.dark .table tbody td    { color: #cbd5e1; border-color: #2d3f55; }
html.dark .table tbody tr:hover { background: #162032; }
html.dark .table-light,
html.dark .table-light > td,
html.dark .table-light > th  { background: #162032 !important; color: #94a3b8; }

html.dark .form-control,
html.dark .form-select  { background: #0f172a; color: #e2e8f0; border-color: #475569; }
html.dark .form-control:focus,
html.dark .form-select:focus { background: #0f172a; color: #e2e8f0; border-color: var(--primary); }
html.dark .form-label   { color: #cbd5e1; }
html.dark .form-text    { color: #94a3b8; }

html.dark .input-group-text { background: #162032; border-color: #475569; color: #94a3b8; }

html.dark .btn-outline-secondary { color: #94a3b8; border-color: #475569; }
html.dark .btn-outline-secondary:hover { background: #334155; color: #e2e8f0; border-color: #334155; }

html.dark .stat-card    { background: #1e293b; border-color: #334155; }
html.dark .stat-value   { color: #f1f5f9; }
html.dark .stat-label   { color: #94a3b8; }

html.dark .page-header h5 { color: #f1f5f9; }
html.dark .text-muted   { color: #94a3b8 !important; }
html.dark .text-dark    { color: #e2e8f0 !important; }
html.dark code          { color: #93c5fd; background: transparent; }
html.dark .bg-light     { background: #162032 !important; }
html.dark hr            { border-color: #334155; }
html.dark .alert        { background: #162032; border-color: #334155; }
html.dark .pagination .page-link { background: #1e293b; border-color: #334155; color: #94a3b8; }
html.dark .pagination .page-item.active .page-link { background: var(--primary); border-color: var(--primary); color: #fff; }
html.dark .pagination .page-item.disabled .page-link { background: #162032; color: #475569; }
html.dark .nav-tabs { border-color: #334155; }
html.dark .nav-tabs .nav-link { color: #94a3b8; border-color: transparent; }
html.dark .nav-tabs .nav-link:hover { color: #e2e8f0; border-color: #334155 #334155 transparent; background: transparent; }
html.dark .nav-tabs .nav-link.active { color: #e2e8f0; background: #1e293b; border-color: #334155 #334155 #1e293b; }
html.dark .table-responsive { background: #1e293b; }

/* ---- Print ---- */
@media print {
    .sidebar, .topbar, .d-print-none,
    .page-header .d-flex, .card-header .d-flex,
    .btn, form, nav, .pagination { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .content-area { padding: 0 !important; }
    .card { border: none !important; box-shadow: none !important; }
    .card-header { border-bottom: 2px solid #333 !important; }
    body { background: #fff !important; color: #000 !important; }
    .page-header { margin-bottom: 12px; }
    .page-header h5 { color: #000 !important; }
    .table tbody td, .table thead th { color: #000 !important; }
    a { text-decoration: none; color: inherit; }
}
