/* ========== Design System - Diaandpao ========== */
:root {
  /* Colors */
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-light: #dbeafe;
  --color-secondary: #64748b;
  --color-secondary-hover: #475569;
  --color-success: #059669;
  --color-success-bg: #d1fae5;
  --color-danger: #dc2626;
  --color-danger-hover: #b91c1c;
  --color-danger-bg: #fee2e2;
  --color-warning: #d97706;
  --color-warning-bg: #fef3c7;
  --color-bg: #f1f5f9;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-sidebar-bg: #0f172a;
  --color-sidebar-text: #e2e8f0;
  --color-sidebar-hover: #1e293b;
  --color-sidebar-active: #2563eb;
  --color-sidebar-active-bg: rgba(37, 99, 235, 0.15);

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 2.5rem;

  /* Typography */
  --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --leading-tight: 1.25;
  --leading-normal: 1.5;

  /* Radius & shadow */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);

  /* Focus */
  --focus-ring: 2px solid var(--color-primary);
  --focus-offset: 2px;
}

/* ========== Base ========== */
*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background: var(--color-bg);
}

:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0 0 var(--space-md); line-height: var(--leading-tight); }
h1 { font-size: var(--text-2xl); font-weight: 700; }
h2 { font-size: var(--text-xl); font-weight: 600; }
h3 { font-size: var(--text-lg); font-weight: 600; }

/* ========== Layout - App shell ========== */
.app {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  min-width: 0;
  padding: var(--space-lg) var(--space-xl);
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

/* ========== Sidebar ========== */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--color-sidebar-bg);
  color: var(--color-sidebar-text);
  padding: var(--space-lg) 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, width 0.2s ease;
}

.sidebar-brand {
  padding: 0 var(--space-lg) var(--space-lg);
  font-weight: 700;
  font-size: var(--text-xl);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: var(--space-md);
}

.sidebar-brand a {
  color: inherit;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.sidebar-brand a:hover { text-decoration: none; opacity: 0.9; }

.sidebar-nav {
  list-style: none;
  padding: 0 var(--space-sm);
  margin: 0;
  flex: 1;
}

.sidebar-nav li { margin: 0; }

.sidebar-nav a,
.sidebar-nav .sidebar-item-disabled {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  color: rgba(226, 232, 240, 0.8);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: background 0.15s, color 0.15s;
  margin-bottom: var(--space-xs);
}

.sidebar-nav a:hover {
  background: var(--color-sidebar-hover);
  color: #fff;
  text-decoration: none;
}

.sidebar-nav a.active {
  background: var(--color-sidebar-active-bg);
  color: #fff;
  font-weight: 500;
}

.sidebar-nav .sidebar-item-disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.sidebar-nav .icon { flex-shrink: 0; width: 20px; height: 20px; opacity: 0.9; }

.sidebar-user {
  padding: var(--space-lg);
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: var(--text-sm);
  color: rgba(226, 232, 240, 0.7);
  word-break: break-all;
}

.sidebar-user .btn {
  margin-top: var(--space-sm);
  width: 100%;
  justify-content: center;
}

/* Sidebar mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 40;
}

.sidebar-open .sidebar-overlay { display: block; }

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar-open .sidebar { transform: translateX(0); }
  .main-content { margin-left: 0; }
}

/* ========== Page header (breadcrumbs + actions) ========== */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.page-header h1 { margin: 0; }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-sm);
}

.breadcrumb a { color: var(--color-text-muted); }
.breadcrumb a:hover { color: var(--color-primary); text-decoration: none; }
.breadcrumb span:last-child { color: var(--color-text); font-weight: 500; }

/* ========== Cards ========== */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  overflow: hidden;
}

.card-body { padding: var(--space-lg); }

.card-header {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border);
  font-weight: 600;
  font-size: var(--text-lg);
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 0.5rem 1rem;
  font-size: var(--text-sm);
  font-family: inherit;
  font-weight: 500;
  line-height: 1.5;
  text-decoration: none;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
  text-decoration: none;
  color: #fff;
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-bg);
  text-decoration: none;
  color: var(--color-text);
}

.btn-danger {
  background: var(--color-danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: var(--color-danger-hover);
  text-decoration: none;
  color: #fff;
}

.btn-outline-danger {
  background: transparent;
  color: var(--color-danger);
  border: 1px solid var(--color-danger);
}
.btn-outline-danger:hover:not(:disabled) {
  background: var(--color-danger-bg);
  color: var(--color-danger-hover);
}

.btn-icon-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 1rem;
  color: var(--color-danger);
  transition: opacity 0.15s ease, background 0.15s ease;
}
.btn-icon-danger:hover { background: var(--color-danger-bg); opacity: 1; }
.btn-icon-danger:focus-visible { outline: var(--focus-ring); outline-offset: 2px; }

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: var(--text-xs);
}

.btn-group { display: flex; flex-wrap: wrap; gap: var(--space-sm); align-items: center; }

/* ========== Forms ========== */
.form-group {
  margin-bottom: var(--space-lg);
}

.form-group label {
  display: block;
  margin-bottom: var(--space-xs);
  font-weight: 500;
  font-size: var(--text-sm);
  color: var(--color-text);
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="file"],
.form-group select,
.form-group textarea {
  width: 100%;
  max-width: 28rem;
  padding: 0.5rem 0.75rem;
  font-size: var(--text-base);
  font-family: inherit;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

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

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

.form-help {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
}

.form-actions {
  margin-top: var(--space-xl);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  align-items: center;
}

.form-inline {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.form-inline label { margin: 0 var(--space-sm) 0 0; }
.form-inline select {
  padding: 0.5rem 0.75rem;
  min-width: 12rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

/* ========== Tables ========== */
.table-wrap {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
}

.table-wrap table { width: 100%; border-collapse: collapse; }

.table-wrap th,
.table-wrap td {
  padding: var(--space-md) var(--space-lg);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.table-wrap th {
  background: var(--color-bg);
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--color-text);
}

.table-wrap tbody tr:last-child td { border-bottom: 0; }
.table-wrap tbody tr:hover td { background: var(--color-bg); }

.table-wrap .actions { white-space: nowrap; }
.table-wrap .actions .btn { margin-right: var(--space-sm); }
.table-wrap .actions form { display: inline; }

/* ========== Alerts ========== */
.alert {
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-lg);
  border: 1px solid transparent;
}

.alert-success {
  background: var(--color-success-bg);
  color: #065f46;
  border-color: #a7f3d0;
}

.alert-error {
  background: var(--color-danger-bg);
  color: #991b1b;
  border-color: #fecaca;
}

.alert-info {
  background: var(--color-primary-light);
  color: #1e40af;
  border-color: #93c5fd;
}

/* ========== Badges ========== */
.badge {
  display: inline-block;
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  border-radius: 9999px;
  background: var(--color-bg);
  color: var(--color-text);
}

.badge-primary { background: var(--color-primary-light); color: var(--color-primary); }
.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-full { background: var(--color-warning-bg); color: var(--color-warning); margin-left: var(--space-md); }

.text-warning { color: var(--color-warning); }

.form-hint { font-size: var(--text-sm); color: var(--color-text-muted); margin-top: var(--space-xs); margin-bottom: 0; }

/* ========== Occupancy (summary + progress) ========== */
.occupancy-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-lg);
  margin-bottom: var(--space-md);
}
.occupancy-summary .summary-item {
  display: flex;
  align-items: baseline;
  gap: var(--space-xs);
}
.occupancy-summary .summary-label { font-weight: 500; color: var(--color-text-muted); }
.occupancy-summary .summary-value { font-weight: 700; font-size: var(--text-lg); }
.progress-bar-wrap {
  height: 8px;
  background: var(--color-border);
  border-radius: 9999px;
  overflow: hidden;
}
.progress-bar { height: 100%; position: relative; }
.progress-bar-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 9999px;
  transition: width 0.2s ease;
}
.progress-bar-fill.progress-full { background: var(--color-warning); }

/* ========== Empty state ========== */
.empty-state {
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
  color: var(--color-text-muted);
}

.empty-state p { margin: 0 0 var(--space-md); }

/* ========== Modal (confirm) ========== */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
}

.modal-backdrop.modal-open { display: flex; }

.modal-dialog {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 24rem;
  width: 100%;
  padding: var(--space-xl);
}

.modal-dialog h3 { margin-top: 0; }
.modal-dialog .modal-actions {
  margin-top: var(--space-lg);
  display: flex;
  gap: var(--space-md);
  justify-content: flex-end;
}

/* ========== Login page ========== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  background: linear-gradient(135deg, var(--color-sidebar-bg) 0%, #1e293b 100%);
}

.login-main {
  width: 100%;
  max-width: 24rem;
}

.login-card {
  width: 100%;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2xl);
}

.login-title {
  text-align: center;
  margin-bottom: var(--space-xs);
}

.login-subtitle {
  text-align: center;
  color: var(--color-text-muted);
  margin-bottom: var(--space-xl);
}

.login-card h1 {
  text-align: center;
  margin-bottom: var(--space-xs);
}

.login-card .subtitle {
  text-align: center;
  color: var(--color-text-muted);
  margin-bottom: var(--space-xl);
}

.login-card .form-group { max-width: none; }
.login-card .form-group input { max-width: none; }
.login-card .btn { width: 100%; margin-top: var(--space-sm); }

.password-toggle,
.password-wrap {
  position: relative;
}
.password-toggle input,
.password-wrap input[type="password"],
.password-wrap input[type="text"] { padding-right: 5rem; }
.password-toggle .toggle-pwd,
.password-wrap .toggle-pwd {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  color: var(--color-primary);
  font-size: var(--text-sm);
}
.password-wrap .toggle-pwd:hover { text-decoration: underline; }

/* ========== Card section (garment manage) ========== */
.card-section {
  margin-bottom: var(--space-2xl);
}
.card-section .section-header {
  padding: var(--space-lg);
  padding-bottom: var(--space-sm);
}
.card-section .card-body { padding-top: 0; }
.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}
.section-header .section-title { margin-bottom: var(--space-xs); }
.section-header-subtext {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* ========== Drop zone (garment photos) ========== */
.drop-zone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  padding: var(--space-xl);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.drop-zone:hover,
.drop-zone:focus-within { border-color: var(--color-primary); background: var(--color-primary-light); }
.drop-zone.drag-over { border-color: var(--color-primary); background: var(--color-primary-light); }
.drop-zone-input { position: absolute; width: 0.1px; height: 0.1px; opacity: 0; overflow: hidden; clip: rect(0, 0, 0, 0); }
.drop-zone-icon { font-size: 2rem; margin-bottom: var(--space-sm); display: block; }
.drop-zone-text { font-size: var(--text-sm); color: var(--color-text-muted); text-align: center; }
.garment-photos-upload { margin-bottom: var(--space-xl); }
.garment-photos-upload-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin-top: var(--space-md);
}
.photo-counter { font-size: var(--text-sm); color: var(--color-text-muted); }
.photo-counter-suffix { color: var(--color-primary); font-weight: 500; }
.photo-preview-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}
.photo-preview-list img { width: 60px; height: 60px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--color-border); }

/* ========== Photo grid (garment manage) ========== */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-md);
}
.garment-photo-grid {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-lg);
}
.photo-item {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-bg);
}
.photo-item-link { display: block; line-height: 0; }
.photo-item-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  transition: opacity 0.2s ease;
}
.photo-item:hover .photo-item-img { opacity: 0.92; }
.photo-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.photo-item:hover .photo-overlay { opacity: 1; }
.photo-overlay-form { margin: 0; }

.photo-thumb {
  text-align: center;
}
.photo-thumb img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}
.photo-thumb p { font-size: var(--text-xs); margin: var(--space-sm) 0; color: var(--color-text-muted); }

/* ========== Empty state with icon ========== */
.empty-state-icon { text-align: center; padding: var(--space-2xl) var(--space-lg); }
.empty-state-icon-symbol { font-size: 3rem; display: block; margin-bottom: var(--space-md); opacity: 0.8; }
.empty-state-icon-photo { font-size: 3.5rem; }
.empty-state-icon p { margin: 0 0 var(--space-lg); color: var(--color-text-muted); }

/* ========== Table spaced ========== */
.table-spaced th { padding: var(--space-md) var(--space-lg); }
.table-spaced td { padding: var(--space-md) var(--space-lg); }

/* ========== Sections ========== */
.section { margin-bottom: var(--space-2xl); }
.section-title { margin-bottom: var(--space-md); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-md); }

/* ========== Utilities ========== */
.text-muted { color: var(--color-text-muted); }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: var(--space-md); }
.mt-1 { margin-top: var(--space-sm); }
.mt-2 { margin-top: var(--space-md); }
.list-unstyled { list-style: none; padding: 0; margin: 0; }
.form-error { color: var(--color-danger); font-size: var(--text-sm); margin-top: var(--space-xs); }

/* Mobile menu button */
.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  margin-bottom: var(--space-md);
}

@media (max-width: 768px) {
  .menu-toggle { display: inline-flex; }
  .main-content { padding: var(--space-md); }
}
