/* ============================================================
   IMS — Inventory Management System
   Clean, professional industrial/utility aesthetic
   ============================================================ */

:root {
  --primary:       #0055A5;
  --primary-dark:  #003d7a;
  --primary-light: #1a7fd4;
  --accent:        #f0a500;
  --success:       #1e7d4f;
  --danger:        #c0392b;
  --warning:       #d68910;
  --info:          #1a6fa8;

  --bg:            #f0f2f5;
  --surface:       #ffffff;
  --border:        #dde1e7;
  --border-light:  #eaeef3;

  --text:          #1a2332;
  --text-muted:    #6b7a90;
  --text-light:    #9aa5b4;

  --sidebar-bg:    #0d1b2e;
  --sidebar-text:  rgba(255,255,255,0.75);
  --sidebar-hover: rgba(255,255,255,0.08);
  --sidebar-active:#0055A5;

  --radius:        8px;
  --radius-lg:     12px;
  --shadow:        0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:     0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg:     0 8px 32px rgba(0,0,0,0.15);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── LAYOUT ── */
.app-layout { display: flex; height: 100vh; overflow: hidden; }
.main-content { flex: 1; overflow-y: auto; padding: 24px 28px; min-width: 0; }

/* ── SIDEBAR ── */
.sidebar {
  width: 240px; min-width: 240px; background: var(--sidebar-bg);
  display: flex; flex-direction: column; height: 100vh; overflow-y: auto; flex-shrink: 0;
}
.sidebar-header { padding: 20px 18px 16px; border-bottom: 1px solid rgba(255,255,255,0.07); }
.sidebar-logo { font-size: 1.6rem; margin-bottom: 8px; }
.sidebar-title { font-weight: 700; font-size: 0.95rem; color: #fff; line-height: 1.2; }
.sidebar-subtitle { font-size: 0.72rem; color: var(--sidebar-text); margin-top: 2px; }
.sidebar-nav { flex: 1; padding: 10px 0; overflow-y: auto; }
.nav-section { margin-bottom: 4px; }
.nav-section-label {
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: rgba(255,255,255,0.3); padding: 10px 18px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 18px;
  cursor: pointer; color: var(--sidebar-text); font-size: 0.85rem; font-weight: 500;
  border: none; background: none; width: 100%; text-align: left; transition: all 0.15s;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.nav-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-user {
  padding: 14px 18px; border-top: 1px solid rgba(255,255,255,0.07);
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 0.8rem; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 600; font-size: 0.82rem; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.7rem; color: var(--sidebar-text); text-transform: capitalize; }
.logout-btn {
  background: none; border: none; color: rgba(255,255,255,0.4);
  cursor: pointer; font-size: 1rem; padding: 4px; border-radius: 6px;
  transition: color 0.15s; flex-shrink: 0;
}
.logout-btn:hover { color: var(--danger); }

/* ── PAGE HEADER ── */
.page-header { margin-bottom: 24px; }
.page-header h2 { font-size: 1.35rem; font-weight: 700; color: var(--text); margin-bottom: 3px; }
.page-header p { color: var(--text-muted); font-size: 0.85rem; }
.flex-between { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.flex { display: flex; align-items: center; }
.gap-2 { gap: 8px; }

/* ── CARDS ── */
.card {
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--border); padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px;
}
.card-title {
  font-weight: 700; font-size: 0.88rem; color: var(--text);
  margin-bottom: 14px; display: flex; align-items: center; gap: 6px;
}

/* ── STATS GRID ── */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px; margin-bottom: 20px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px 18px; box-shadow: var(--shadow);
}
.stat-label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 6px; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--text); line-height: 1; margin-bottom: 4px; word-break: break-word; }
.stat-value.green { color: var(--success); }
.stat-value.amber { color: var(--warning); }
.stat-value.red   { color: var(--danger); }
.stat-value.blue  { color: var(--primary); }
.stat-sub { font-size: 0.73rem; color: var(--text-muted); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius); font-size: 0.83rem; font-weight: 600;
  font-family: inherit; cursor: pointer; border: 1.5px solid transparent;
  transition: all 0.15s; white-space: nowrap; line-height: 1.4;
}
.btn-primary   { background: var(--primary);   color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); border-color: #bcc4d0; }
.btn-success   { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #186640; }
.btn-danger    { background: var(--danger);  color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #a93226; }
.btn-warning   { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-sm { padding: 5px 10px; font-size: 0.78rem; }
.btn-icon { padding: 5px 8px; min-width: 32px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ── FORMS ── */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block; font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 5px;
}
.form-control {
  width: 100%; padding: 8px 12px; border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: 0.88rem; font-family: inherit; color: var(--text); background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s; outline: none; min-height: 36px;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,85,165,0.1); }
.form-control[readonly] { background: #f5f7fa; color: var(--text-muted); cursor: default; }
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.required { color: var(--danger); }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
thead th {
  background: var(--bg); color: var(--text-muted); font-weight: 600; font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 0.06em; padding: 10px 12px;
  text-align: left; border-bottom: 2px solid var(--border); white-space: nowrap;
}
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
tbody tr:hover { background: #fafbfc; }
tbody tr:last-child td { border-bottom: none; }
tfoot td { padding: 10px 12px; border-top: 2px solid var(--border); }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); font-size: 0.82rem; }

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center; padding: 2px 8px;
  border-radius: 20px; font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.03em; white-space: nowrap;
}
.badge-primary { background: #dce8f5; color: var(--primary); }
.badge-success, .badge-green { background: #d4edda; color: var(--success); }
.badge-danger,  .badge-red   { background: #fde8e7; color: var(--danger); }
.badge-warning, .badge-amber { background: #fef3cd; color: #856404; }
.badge-info,    .badge-blue  { background: #dce8f5; color: var(--info); }
.badge-gray     { background: #e9ecef; color: #6c757d; }
.badge-developer { background: #1a2332; color: #f0a500; }

/* ── MODALS ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px; backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto; animation: modalIn 0.2s ease;
  display: flex; flex-direction: column;
}
.modal-xl  { max-width: 1200px; width: 96vw; }
.modal-xxl { max-width: 1460px; width: 98vw; }
.modal-lg  { max-width: 720px; }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  flex-shrink: 0; background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0; position: sticky; top: 0; z-index: 1;
}
.modal-header h3 { font-size: 1rem; font-weight: 700; color: var(--text); }
.modal-close {
  background: none; border: none; font-size: 1.4rem; color: var(--text-muted);
  cursor: pointer; padding: 2px 8px; border-radius: 6px; line-height: 1;
  transition: background 0.15s; flex-shrink: 0;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 20px; flex: 1; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px; border-top: 1px solid var(--border);
  background: var(--bg); border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  flex-shrink: 0; position: sticky; bottom: 0;
}

/* ── ALERTS ── */
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 0.83rem; margin-bottom: 14px; line-height: 1.5; }
.alert-info    { background: #dce8f5; color: var(--info);    border-left: 3px solid var(--info); }
.alert-success { background: #d4edda; color: var(--success); border-left: 3px solid var(--success); }
.alert-warning { background: #fef3cd; color: #856404;        border-left: 3px solid var(--warning); }
.alert-danger  { background: #fde8e7; color: var(--danger);  border-left: 3px solid var(--danger); }

/* ── DIVIDER ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ── TABS ── */
.tabs {
  display: flex; gap: 2px; margin-bottom: 16px;
  border-bottom: 2px solid var(--border); overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.tab {
  padding: 8px 14px; border: none; background: none; font-family: inherit;
  font-size: 0.83rem; font-weight: 600; color: var(--text-muted); cursor: pointer;
  border-radius: var(--radius) var(--radius) 0 0; transition: all 0.15s;
  position: relative; bottom: -2px; white-space: nowrap; flex-shrink: 0;
}
.tab:hover { color: var(--primary); background: rgba(0,85,165,0.05); }
.tab.active { color: var(--primary); border-bottom: 2px solid var(--primary); }

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-icon { font-size: 2.5rem; margin-bottom: 10px; }
.empty-state p { font-size: 0.88rem; }

/* ── PAGINATION ── */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; gap: 8px;
}
.pagination-info { font-size: 0.8rem; color: var(--text-muted); }
.pagination-controls { display: flex; gap: 4px; flex-wrap: wrap; }
.page-btn {
  padding: 4px 10px; border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text); border-radius: 6px; cursor: pointer; font-size: 0.8rem;
  font-family: inherit; transition: all 0.12s; min-width: 32px; text-align: center;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── DATE FILTER ── */
.date-filter-btn {
  padding: 5px 10px; border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text-muted); border-radius: 6px; cursor: pointer; font-size: 0.78rem;
  font-weight: 600; font-family: inherit; transition: all 0.12s; white-space: nowrap;
}
.date-filter-btn:hover { border-color: var(--primary); color: var(--primary); }
.date-filter-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── LOGIN ── */
.login-bg {
  min-height: 100vh;
  background: linear-gradient(135deg, #0d1b2e 0%, #0055A5 100%);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card {
  background: #fff; border-radius: 20px; padding: 48px 40px;
  max-width: 420px; width: 100%; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-logo { font-size: 3rem; margin-bottom: 12px; display: flex; align-items: center; justify-content: center; }
.login-card h1 { font-size: 1.5rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.login-card p  { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 28px; }
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 12px 20px; border: 1.5px solid var(--border);
  border-radius: var(--radius-lg); background: #fff; cursor: pointer; font-family: inherit;
  font-size: 0.9rem; font-weight: 600; color: var(--text); transition: all 0.15s;
}
.google-btn:hover { background: var(--bg); border-color: #bcc4d0; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.google-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.google-icon { width: 20px; height: 20px; flex-shrink: 0; }
.access-denied {
  margin-top: 14px; padding: 10px 14px; background: #fde8e7; color: var(--danger);
  border-radius: var(--radius); font-size: 0.82rem; text-align: left;
}

/* ── LOADING ── */
.loading-overlay {
  position: fixed; inset: 0; background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; z-index: 9999;
}
.spinner {
  width: 36px; height: 36px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
.spinner-sm { width: 20px; height: 20px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--text-muted); font-size: 0.88rem; }

/* ── TOASTS ── */
.toast-container {
  position: fixed; bottom: 20px; right: 20px;
  z-index: 3000; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-radius: var(--radius); font-size: 0.85rem; font-weight: 500;
  box-shadow: var(--shadow-md); animation: toastIn 0.25s ease; max-width: 380px;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: none; }
}
.toast-success { background: #1e7d4f; color: #fff; }
.toast-error   { background: #c0392b; color: #fff; }
.toast-warning { background: #d68910; color: #fff; }
.toast-info    { background: var(--primary); color: #fff; }

/* ── RR CODE ── */
.rr-code { font-family: 'Courier New', monospace; font-weight: 700; color: var(--primary); font-size: 0.85rem; }

/* ── ITEMS TABLE ── */
.items-table th, .items-table td { padding: 8px 10px; }
.items-table input, .items-table select { padding: 6px 8px; font-size: 0.82rem; }

/* ── GRID ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── STOCK COLORS ── */
.stock-ok      { color: var(--success); font-weight: 600; }
.stock-warning { color: var(--warning); font-weight: 600; }
.stock-low     { color: var(--danger);  font-weight: 600; }

/* ── DEV BANNER ── */
.dev-banner {
  background: #1a2332; color: #f0a500; border-radius: 8px;
  padding: 8px 16px; margin-bottom: 16px; display: flex;
  justify-content: space-between; align-items: center; font-size: 0.82rem; gap: 8px;
}

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .form-row-3 { grid-template-columns: 1fr 1fr; }
  .stats-grid[style*="repeat(4"] { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { padding: 16px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .modal-xl, .modal-xxl, .modal-lg { max-width: 100%; width: 100%; }
  .flex-between { flex-direction: column; align-items: stretch; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .login-card { padding: 32px 24px; }
}
