@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Sans:wght@300;400;500;600&display=swap');

:root {
  --cream: #F5F0E8;
  --warm-white: #FAFAF7;
  --charcoal: #1C1C1A;
  --mid-grey: #5A5A55;
  --light-grey: #D4D0C8;
  --border: #E0DBD0;
  --accent: #C8873A;
  --accent-light: #F0D4B0;
  --accent-dark: #A06828;
  --green: #4A7C59;
  --green-light: #D4EBD9;
  --red: #B84A3A;
  --red-light: #F5D4D0;
  --blue: #3A6080;
  --blue-light: #D0E4F0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.15);
  --radius: 10px;
  --radius-sm: 6px;
  --sidebar-w: 260px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--cream);
  color: var(--charcoal);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── LAYOUT ── */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--charcoal);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .3s ease;
}

.sidebar-logo {
  padding: 22px 24px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo img { filter: brightness(0) invert(1) sepia(1) saturate(3) hue-rotate(5deg); opacity: 0.95; }
.sidebar-logo p { color: rgba(255,255,255,0.4); font-size: 0.68rem; margin-top: 8px; letter-spacing: 0.1em; text-transform: uppercase; }

.sidebar-nav { flex: 1; padding: 16px 0; overflow-y: auto; }
.nav-section { padding: 0 12px 8px; }
.nav-section-label {
  color: rgba(255,255,255,0.3);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 10px 12px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all .2s;
  margin-bottom: 2px;
}
.nav-link:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-link.active { background: var(--accent); color: #fff; }
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.user-badge {
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius-sm);
}
.user-avatar {
  width: 34px; height: 34px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 600; color: #fff;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { color: #fff; font-size: 0.825rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { color: rgba(255,255,255,0.4); font-size: 0.7rem; text-transform: capitalize; }

.logout-btn {
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,0.4); padding: 4px;
  display: flex; align-items: center;
  transition: color .2s;
}
.logout-btn:hover { color: var(--red); }

/* ── MAIN CONTENT ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--warm-white);
  border-bottom: 1px solid var(--border);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title { font-family: 'DM Serif Display', serif; font-size: 1.4rem; color: var(--charcoal); }
.topbar-subtitle { color: var(--mid-grey); font-size: 0.825rem; margin-top: 1px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.page-content { padding: 32px; flex: 1; }

/* ── CARDS ── */
.card {
  background: var(--warm-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--warm-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s;
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--mid-grey); margin-bottom: 8px; }
.stat-value { font-family: 'DM Serif Display', serif; font-size: 2.4rem; color: var(--charcoal); line-height: 1; }
.stat-sub { font-size: 0.75rem; color: var(--mid-grey); margin-top: 6px; }
.stat-card.accent { border-top: 3px solid var(--accent); }
.stat-card.green { border-top: 3px solid var(--green); }
.stat-card.red { border-top: 3px solid var(--red); }
.stat-card.blue { border-top: 3px solid var(--blue); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all .2s;
  text-decoration: none;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: var(--cream); border: 1px solid var(--border); color: var(--charcoal); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #932e20; }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #3a6347; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── FORMS ── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 0.825rem; font-weight: 600; color: var(--charcoal); margin-bottom: 6px; }
.form-label.required::after { content: ' *'; color: var(--red); }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  background: var(--warm-white);
  color: var(--charcoal);
  transition: border-color .2s, box-shadow .2s;
  appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 0.75rem; color: var(--mid-grey); margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── SEARCH BAR ── */
.search-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 20px;
}
.search-input-wrap { position: relative; flex: 1; }
.search-input-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--mid-grey); }
.search-input { padding-left: 38px !important; }

/* ── TABLES ── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; background: var(--warm-white); }
thead { background: var(--cream); }
th { padding: 11px 16px; text-align: left; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--mid-grey); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 0.875rem; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--cream); }

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
}
.badge-available { background: var(--green-light); color: var(--green); }
.badge-on_hire { background: var(--accent-light); color: var(--accent-dark); }
.badge-maintenance { background: var(--blue-light); color: var(--blue); }
.badge-retired { background: var(--light-grey); color: var(--mid-grey); }
.badge-pending { background: var(--blue-light); color: var(--blue); }
.badge-active { background: var(--green-light); color: var(--green); }
.badge-completed { background: var(--light-grey); color: var(--mid-grey); }
.badge-cancelled { background: var(--red-light); color: var(--red); }
.badge-excellent { background: var(--green-light); color: var(--green); }
.badge-good { background: #e8f4e8; color: #2d7a3a; }
.badge-fair { background: var(--accent-light); color: var(--accent-dark); }
.badge-poor { background: var(--red-light); color: var(--red); }
.badge-furniture { background: var(--accent-light); color: var(--accent-dark); }
.badge-accessory { background: var(--blue-light); color: var(--blue); }

/* ── ITEM CARDS (grid) ── */
.items-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.item-card {
  background: var(--warm-white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow .2s, transform .15s;
  cursor: pointer;
}
.item-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.item-card-img {
  width: 100%; aspect-ratio: 4/3;
  object-fit: cover;
  background: var(--cream);
}
.item-card-no-img {
  width: 100%; aspect-ratio: 4/3;
  background: var(--cream);
  display: flex; align-items: center; justify-content: center;
  color: var(--light-grey);
}
.item-card-no-img svg { width: 48px; height: 48px; }
.item-card-body { padding: 14px; }
.item-card-name { font-weight: 600; font-size: 0.9rem; color: var(--charcoal); margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-card-barcode { font-size: 0.72rem; color: var(--mid-grey); font-family: monospace; margin-bottom: 8px; }
.item-card-footer { display: flex; justify-content: space-between; align-items: center; }

/* ── MODALS ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity .25s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--warm-white);
  border-radius: var(--radius);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform .25s;
  display: flex;
  flex-direction: column;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-lg { max-width: 860px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 22px 26px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-title { font-family: 'DM Serif Display', serif; font-size: 1.3rem; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--mid-grey); padding: 4px; transition: color .2s; }
.modal-close:hover { color: var(--charcoal); }
.modal-body { padding: 26px; overflow-y: auto; flex: 1; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 26px; border-top: 1px solid var(--border); flex-shrink: 0; background: var(--warm-white); border-radius: 0 0 var(--radius) var(--radius); }

/* ── SCAN INTERFACE ── */
.scan-container { max-width: 680px; margin: 0 auto; }
.scan-input-area {
  background: var(--warm-white);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  margin-bottom: 24px;
  transition: border-color .2s;
}
.scan-input-area.ready { border-color: var(--green); }
.scan-input-area.error { border-color: var(--red); }
.scan-big-input {
  font-size: 1.4rem;
  padding: 16px 20px;
  text-align: center;
  letter-spacing: 2px;
  font-family: 'Courier New', monospace;
  width: 100%;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--cream);
  color: var(--charcoal);
  transition: border-color .2s;
}
.scan-big-input:focus { outline: none; border-color: var(--accent); }
.scan-result { padding: 20px; background: var(--cream); border-radius: var(--radius); margin-top: 16px; }
.scan-result.success { background: var(--green-light); border: 1.5px solid var(--green); }
.scan-result.error { background: var(--red-light); border: 1.5px solid var(--red); }

/* ── IMAGE UPLOAD ── */
.img-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  background: var(--cream);
}
.img-upload-area:hover, .img-upload-area.dragover { border-color: var(--accent); background: var(--accent-light); }
.img-preview { width: 100%; max-height: 200px; object-fit: cover; border-radius: var(--radius-sm); margin-top: 10px; }
.img-upload-icon { color: var(--mid-grey); margin-bottom: 8px; }

/* ── ALERTS ── */
.alert { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 0.875rem; }
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: var(--green-light); color: var(--green); border: 1px solid var(--green); }
.alert-error { background: var(--red-light); color: var(--red); border: 1px solid var(--red); }
.alert-warning { background: var(--accent-light); color: var(--accent-dark); border: 1px solid var(--accent); }
.alert-info { background: var(--blue-light); color: var(--blue); border: 1px solid var(--blue); }

/* ── PAGINATION ── */
.pagination { display: flex; align-items: center; gap: 6px; margin-top: 20px; justify-content: center; }
.page-btn {
  padding: 7px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--warm-white);
  color: var(--charcoal);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all .2s;
}
.page-btn:hover, .page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-btn:disabled { opacity: 0.4; cursor: default; }

/* ── TOAST ── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; }
.toast {
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  font-weight: 500;
  min-width: 280px;
  animation: slideIn .3s ease;
  display: flex; align-items: center; gap: 10px;
}
.toast.success { background: var(--charcoal); color: #fff; }
.toast.error { background: var(--red); color: #fff; }
.toast.warning { background: var(--accent); color: #fff; }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── TABS ── */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--border); margin-bottom: 24px; }
.tab-btn { padding: 10px 18px; background: none; border: none; font-family: 'DM Sans', sans-serif; font-size: 0.875rem; font-weight: 500; color: var(--mid-grey); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .2s; }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-btn:hover { color: var(--charcoal); }

/* ── MISC ── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--mid-grey); }
.empty-state svg { width: 56px; height: 56px; margin-bottom: 16px; opacity: 0.4; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: 8px; color: var(--charcoal); }
.loading { text-align: center; padding: 40px; color: var(--mid-grey); }
.spinner { display: inline-block; width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-sm { font-size: 0.8rem; }
.text-muted { color: var(--mid-grey); }
.font-mono { font-family: 'Courier New', monospace; }
.w-full { width: 100%; }
.item-thumb { width: 44px; height: 44px; border-radius: var(--radius-sm); object-fit: cover; background: var(--cream); flex-shrink: 0; }

/* ── LOGIN PAGE ── */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--cream);
}
.login-left {
  background: var(--charcoal);
  padding: 60px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.login-right {
  padding: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-form-box { width: 100%; max-width: 400px; }
.login-brand h1 { font-family: 'DM Serif Display', serif; font-size: 3rem; color: #fff; line-height: 1.1; margin-bottom: 20px; }
.login-brand h1 span { color: var(--accent); }
.login-brand img { margin-bottom: 28px; filter: brightness(10); }
.login-brand p { color: var(--light-grey); font-size: 1.05rem; max-width: 380px; }
.login-features { margin-top: 40px; display: flex; flex-direction: column; gap: 16px; }
.login-feature { display: flex; align-items: center; gap: 14px; color: rgba(255,255,255,0.7); }
.login-feature-dot { width: 8px; height: 8px; background: var(--accent); border-radius: 50%; flex-shrink: 0; }
.login-form-box h2 { font-family: 'DM Serif Display', serif; font-size: 2rem; margin-bottom: 8px; }
.login-form-box p { color: var(--mid-grey); margin-bottom: 32px; }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .login-page { grid-template-columns: 1fr; }
  .login-left { display: none; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .page-content { padding: 20px; }
}

.mobile-menu-btn { display: none; }
@media (max-width: 900px) {
  .mobile-menu-btn { display: flex; }
}

.section-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 22px; }
.section-header h2 { font-family: 'DM Serif Display', serif; font-size: 1.5rem; }
.section-header p { color: var(--mid-grey); font-size: 0.825rem; margin-top: 3px; }
