/* =====================================================
   Store Layout Planner — Global Styles
   Minimal Light Theme | Desktop First
   ===================================================== */

:root {
  --bg-base:      #ffffff;
  --bg-surface:   #ffffff;
  --bg-elevated:  #fafafa;
  --bg-hover:     #f5f5f5;
  --border:       #e5e5e5;
  --border-light: #d4d4d4;

  --text-primary:   #000000;
  --text-secondary: #525252;
  --text-muted:     #737373;

  --accent:         #000000;
  --accent-hover:   #090909;
  --accent-dim:     rgba(0,0,0,.08);

  --success:  #22c55e;
  --warning:  #f59e0b;
  --danger:   #ef4444;
  --info:     #38bdf8;

  --radius:   8px;
  --radius-lg:12px;
  --shadow:   0 16px 40px rgba(0,0,0,.08);
  --shadow-sm:0 8px 22px rgba(0,0,0,.06);
}

html[data-theme="dark"] {
  --bg-base:      #0f172a;
  --bg-surface:   #111827;
  --bg-elevated:  #1f2937;
  --bg-hover:     #273449;
  --border:       #334155;
  --border-light: #475569;

  --text-primary:   #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted:     #94a3b8;

  --accent:         #f8fafc;
  --accent-hover:   #e5e7eb;
  --accent-dim:     rgba(248,250,252,.10);

  --shadow:   0 18px 44px rgba(0,0,0,.35);
  --shadow-sm:0 10px 26px rgba(0,0,0,.28);
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Rounded', 'Noto Sans Thai', system-ui, sans-serif;
  font-size: 14px;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
}

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

/* ── Scrollbar ────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-elevated); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 999px; }

/* ── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 9999px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, border-color .15s, opacity .15s, transform .1s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
html[data-theme="dark"] .btn-primary { color:#000; }
.btn-secondary { background: var(--bg-base); color: var(--text-primary); border: 1px solid var(--border-light); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-success   { background: var(--success); color: #fff; }
.btn-ghost     { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); text-decoration:none; }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 7px; }
.theme-toggle { justify-content:center; min-width:36px; }
.theme-toggle .theme-light-icon { display:none; }
html[data-theme="dark"] .theme-toggle .theme-light-icon { display:inline; }
html[data-theme="dark"] .theme-toggle .theme-dark-icon { display:none; }

/* ── Forms ────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .04em; }

input, select, textarea {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 9999px;
  color: var(--text-primary);
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.5);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
select option { background: var(--bg-surface); color:var(--text-primary); }
textarea { resize: vertical; min-height: 80px; border-radius:12px; }

/* ── Cards ────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

/* ── Badges ───────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}
.badge-green   { background: #f0fdf4; color: #15803d; border:1px solid #bbf7d0; }
.badge-red     { background: #fef2f2; color: #b91c1c; border:1px solid #fecaca; }
.badge-yellow  { background: #fffbeb; color: #b45309; border:1px solid #fde68a; }
.badge-blue    { background: #eff6ff; color: #1d4ed8; border:1px solid #bfdbfe; }
.badge-purple  { background: #fafafa; color: var(--text-primary); border:1px solid var(--border-light); }

/* ── Table ────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--bg-elevated);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}
tbody tr { border-top: 1px solid var(--border); transition: background .1s; }
tbody tr:hover { background: var(--bg-elevated); }
td { padding: 10px 14px; vertical-align: middle; }

/* ── Modal ────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(255,255,255,.72);
  backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
html[data-theme="dark"] .modal-overlay { background: rgba(0,0,0,.58); }
.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 480px;
  max-width: calc(100vw - 32px);
  box-shadow: var(--shadow);
  transform: scale(.96) translateY(8px);
  transition: transform .2s;
}
.modal-overlay.open .modal { transform: scale(1) translateY(0); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 15px; font-weight: 700; }
.modal-body { padding: 20px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

/* ── Toast Notification ───────────────────────────── */
#toast-container {
  position: fixed; top: 20px; right: 20px;
  z-index: 99999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 1px solid var(--accent);
  border-radius: 12px;
  box-shadow: var(--shadow);
  min-width: 280px;
  animation: slideIn .25s ease-out;
}
.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Navbar ───────────────────────────────────────── */
.navbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.navbar-brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 16px; color: var(--text-primary);
}
.navbar-brand .logo-icon {
  width: 32px; height: 32px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 9999px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.navbar-nav { display: flex; align-items: center; gap: 4px; }
.nav-link {
  padding: 6px 12px;
  border-radius: 9999px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-link:hover, .nav-link.active {
  background: var(--bg-hover);
  color: var(--text-primary);
  text-decoration: none;
}
.navbar-user {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-secondary); font-size: 13px;
}
.avatar {
  width: 32px; height: 32px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  color: var(--text-primary);
}

/* ── Page wrapper ─────────────────────────────────── */
.page-wrapper { max-width: 1280px; margin: 0 auto; padding: 28px 24px; }
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.page-title { font-size: 24px; font-weight: 600; letter-spacing:0; }
.page-subtitle { color: var(--text-secondary); font-size: 13px; margin-top: 2px; }

/* ── Stat Cards ───────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px,1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.stat-label { font-size: 12px; font-weight: 500; color: var(--text-muted); text-transform:none; letter-spacing:0; margin-bottom: 8px; }
.stat-value { font-size: 30px; font-weight: 500; color: var(--text-primary); }
.stat-sub   { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Utility ──────────────────────────────────────── */
.d-flex      { display: flex; }
.align-center{ align-items: center; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }
.flex-1      { flex: 1; }
.text-muted  { color: var(--text-muted); }
.text-sm     { font-size: 12px; }
.fw-600      { font-weight: 600; }
.mt-4        { margin-top: 4px; }
.mt-16       { margin-top: 16px; }
.mb-16       { margin-bottom: 16px; }
.w-full      { width: 100%; }
.hidden      { display: none !important; }

/* ── Loading Spinner ─────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Login Page ──────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-base);
  padding:24px;
}
.login-box {
  width: 400px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: none;
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo .icon {
  width: 56px; height: 56px;
  background: var(--bg-elevated);
  border:1px solid var(--border);
  border-radius: 9999px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 28px;
  margin-bottom: 12px;
}
.login-logo h1 { font-size: 30px; font-weight: 500; letter-spacing:0; }
.login-logo p  { color: var(--text-muted); font-size: 13px; }
.login-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 12px;
  color: var(--danger);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.login-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 12px;
  color: var(--success);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.login-switch {
  display: flex;
  justify-content: center;
  margin-top: 14px;
}

/* ── Project Grid ─────────────────────────────────── */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}
.project-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s, transform .15s;
}
.project-card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.project-thumb {
  width: 100%; height: 160px;
  background: var(--bg-elevated);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.project-thumb img { width: 100%; height: 100%; object-fit: cover; }
.project-thumb .thumb-placeholder { color: var(--text-muted); font-size: 40px; }
.project-info { padding: 14px 16px; }
.project-name { font-weight: 500; font-size: 14px; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-meta { font-size: 11px; color: var(--text-muted); }
.project-actions {
  display: flex; gap: 6px;
  padding: 8px 12px 12px;
  border-top: 1px solid var(--border);
}
