/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Enforce ALL CAPS for all data entry fields ── */
input.form-control,
textarea.form-control,
select.form-control {
    text-transform: uppercase;
}
/* Exceptions: password fields, date/number inputs, search boxes stay as-is */
input[type="password"],
input[type="date"],
input[type="number"],
input[type="email"],
input[type="month"],
input[id*="search"],
input[id*="filter"],
input[placeholder*="Search"],
input[placeholder*="search"] {
    text-transform: none;
}

:root {
    --primary:    #1a56db;
    --primary-dk: #1e429f;
    --success:    #057a55;
    --warning:    #c27803;
    --danger:     #c81e1e;
    --bg:         #f3f4f6;
    --sidebar-bg: #111827;
    --sidebar-w:  240px;
    --white:      #ffffff;
    --border:     #e5e7eb;
    --text:       #111827;
    --text-muted: #6b7280;
    --radius:     8px;
    --shadow:     0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:  0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

/* ===== LAYOUT ===== */
.layout { display: flex; min-height: 100vh; }

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: #d1d5db;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-logo {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(26,86,219,0.2);
}

.logo-text {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.logo-sub {
    font-size: 10px;
    color: #6b7280;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar-nav { padding: 12px 0; flex: 1; }

.nav-section {
    padding: 16px 20px 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #4b5563;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    margin: 2px 12px;
    border-radius: 8px;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
}

.nav-item:hover { 
    background: rgba(255,255,255,0.05); 
    color: #f3f4f6; 
}

.nav-item.active { 
    background: var(--primary); 
    color: #fff; 
    box-shadow: 0 4px 12px rgba(26,86,219,0.15);
}

.nav-item .nav-icon {
    width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.nav-item.active .nav-icon {
    opacity: 1;
}

.nav-item:hover .nav-icon {
    opacity: 1;
}

/* ===== MAIN CONTENT ===== */
.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow);
}

.topbar-title { font-size: 16px; font-weight: 600; }

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.page-content { padding: 24px; flex: 1; }

/* ===== CARDS ===== */
.card {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title { font-size: 14px; font-weight: 600; }
.card-body { padding: 20px; }

/* ===== STAT CARDS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.stat-icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.stat-icon.blue   { background: #eff6ff; color: #1a56db; }
.stat-icon.red    { background: #fef2f2; color: #c81e1e; }
.stat-icon.green  { background: #f0fdf4; color: #057a55; }
.stat-icon.yellow { background: #fffbeb; color: #c27803; }

.stat-value { font-size: 26px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ===== TABLES ===== */
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

thead th {
    background: #f9fafb;
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f9fafb; }

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
}

.badge-ok      { background: #d1fae5; color: #065f46; }
.badge-low     { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-blue    { background: #dbeafe; color: #1e40af; }
.badge-gray    { background: #f3f4f6; color: #374151; }
.badge-purchase   { background: #d1fae5; color: #065f46; }
.badge-withdrawal { background: #fee2e2; color: #991b1b; }
.badge-adjustment { background: #fef3c7; color: #92400e; }
.badge-transfer   { background: #ede9fe; color: #5b21b6; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all .15s;
    white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dk); }

.btn-secondary { background: var(--white); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #f9fafb; }

.btn-danger { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; }

.btn-green {background:green; color: white; border-color: white;}
.btn-gree:hover {background:lightgreen; color: white; border-color: black;}

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 6px; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 5px; }
.form-label .required { color: var(--danger); }

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13.5px;
    color: var(--text);
    background: var(--white);
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,86,219,.1);
}

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
    background: var(--white);
    border-radius: 12px;
    width: 100%;
    max-width: 560px;
    max-height: 94vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
    transform: translateY(10px);
    transition: transform .2s;
    overflow: hidden;
}

.modal-overlay.open .modal { transform: translateY(0); }
.modal-lg { max-width: 760px; }
.modal-xl { max-width: 960px; }

.modal-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.modal-title { font-size: 15px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); line-height: 1; }
.modal-body { 
    padding: 20px; 
    overflow-y: auto;
    flex: 1;
}
.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0;
}

/* ===== SEARCH BAR ===== */
.search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.search-input-wrap {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.search-input-wrap .search-icon {
    position: absolute;
    left: 10px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 14px;
}

.search-input-wrap input {
    padding-left: 32px;
}

/* ===== ALERTS ===== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13.5px;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.alert-danger  { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ===== TOAST ===== */
#toast-container {
    position: fixed;
    bottom: 24px; right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: #1f2937;
    color: #fff;
    padding: 12px 18px;
    border-radius: 8px;
    font-size: 13.5px;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn .2s ease;
    max-width: 320px;
}
.toast-icon { display: flex; align-items: center; flex-shrink: 0; }
.toast.success .toast-icon { color: #10b981; }
.toast.error   .toast-icon { color: #ef4444; }
.toast.info    .toast-icon { color: #60a5fa; }

.toast.success { border-left: 4px solid #10b981; }
.toast.error   { border-left: 4px solid #ef4444; }
.toast.info    { border-left: 4px solid #3b82f6; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0);   opacity: 1; }
}

/* ===== PAGINATION ===== */
.pagination {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    justify-content: flex-end;
}

.page-btn {
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--white);
    cursor: pointer;
    font-size: 13px;
    transition: all .15s;
}

.page-btn:hover { background: #f3f4f6; }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ===== LOADING ===== */
.spinner {
    width: 20px; height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .6s linear infinite;
    display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-row td { text-align: center; padding: 32px; }

/* ===== TRANSACTION ITEMS ===== */
.tx-items-table { width: 100%; border-collapse: collapse; }
.tx-items-table th, .tx-items-table td { padding: 8px 10px; border: 1px solid var(--border); font-size: 13px; }
.tx-items-table th { background: #f9fafb; font-weight: 600; }
.tx-items-table .remove-row { cursor: pointer; color: var(--danger); background: none; border: none; font-size: 16px; }

/* ===== CHART CONTAINER ===== */
.chart-container { position: relative; height: 240px; }

/* ===== SIDEBAR USER =====  */
#sidebar-user {
    margin-top: auto;
    border-top: 1px solid rgba(255,255,255,0.05);
    padding: 16px;
}

.user-info-card {
    background: rgba(255,255,255,0.03);
    border-radius: 12px;
    padding: 12px;
    border: 1px solid rgba(255,255,255,0.05);
}

.user-details {
    margin-bottom: 12px;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: #f3f4f6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 11px;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

.user-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.05);
    color: #d1d5db;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.action-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border-color: rgba(255,255,255,0.2);
}

.action-btn.logout:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.2);
}
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s; z-index: 1000; }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; width: 100%; }
    .topbar { padding-left: 60px; } /* Space for hamburger button */
    
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr; }
    
    /* Responsive grids on pages */
    div[style*="display:grid;grid-template-columns:1fr 1fr"],
    div[style*="display:grid;grid-template-columns:1fr 1fr;gap:20px"] {
        grid-template-columns: 1fr !important;
    }
    
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }
    /* Inventory/Purchases filter bar responsiveness */
    div[style*="display:grid;grid-template-columns:1fr auto;gap:16px;align-items:end"] {
        grid-template-columns: 1fr !important;
    }
    div[style*="display:flex;gap:8px"] {
        justify-content: flex-end;
        width: 100%;
    }
}

/* Mobile Toggle Button */
.mobile-toggle {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 1001;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

@media (max-width: 768px) {
    .mobile-toggle { display: block; }
}

/* ===== PRINT ===== */
@media print {
    .sidebar, .topbar, .topbar-actions, .btn, .pagination,
    .modal-close, .card-header .btn, #toast-container { display: none !important; }
    .main { margin-left: 0 !important; }
    .modal-overlay { position: static !important; background: none !important; opacity: 1 !important; pointer-events: all !important; padding: 0 !important; }
    .modal { box-shadow: none !important; max-width: 100% !important; max-height: none !important; }
    .modal-footer { display: none !important; }
    body { font-size: 12px; }
    table { font-size: 11px; }
}
