/* ============================================================
   Sole Thread — Admin panel styles
   ============================================================ */
:root {
  --ink: #17150f;
  --ink-soft: #4b463c;
  --muted: #8a8474;
  --bg: #f4f2ec;
  --card: #ffffff;
  --line: #e7e3d9;
  --accent: #e4572e;
  --accent-dark: #c8431f;
  --accent-soft: #fdeee8;
  --green: #1e9e5a;
  --red: #b91c1c;
  --sidebar-w: 240px;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-md: 0 10px 30px rgba(23, 21, 15, .10);
  --shadow-lg: 0 24px 60px rgba(23, 21, 15, .22);
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); line-height: 1.55; -webkit-font-smoothing: antialiased; }
img { display: block; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: 1rem; }
[hidden] { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 24px; border-radius: 999px; font-weight: 700; font-size: .92rem;
  transition: background .2s ease, transform .15s ease;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-outline { background: #fff; border: 1px solid var(--line); color: var(--ink-soft); }
.btn-outline:hover { border-color: var(--ink); color: var(--ink); }
.btn-sm { padding: 9px 18px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn.loading { pointer-events: none; opacity: .75; }
.btn.loading::after {
  content: ''; width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
.icon-btn { width: 38px; height: 38px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; transition: background .2s ease; }
.icon-btn:hover { background: rgba(23, 21, 15, .07); }
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(1000px 500px at 20% -10%, var(--accent-soft), transparent),
              radial-gradient(800px 400px at 110% 110%, #ece7db, transparent), var(--bg);
}
.login-card {
  width: min(400px, 100%); background: var(--card); border: 1px solid var(--line);
  border-radius: 20px; padding: 38px 34px; box-shadow: var(--shadow-md);
}
.logo { font-weight: 800; font-size: 1.35rem; letter-spacing: .04em; }
.logo span { color: var(--accent); }
.login-sub { color: var(--muted); font-weight: 600; margin: 4px 0 26px; }
.login-hint { margin-top: 18px; font-size: .8rem; color: var(--muted); }
.login-hint code { background: var(--bg); padding: 2px 7px; border-radius: 6px; }

/* ---------- Forms ---------- */
.form-field { margin-bottom: 16px; }
.form-field label { display: block; font-size: .83rem; font-weight: 700; margin-bottom: 6px; }
.form-field input, .form-field select, .form-field textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; outline: none; transition: border-color .15s ease, box-shadow .15s ease; font-size: .94rem;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-error { color: var(--red); font-size: .86rem; font-weight: 600; margin: 2px 0 12px; }
.field-hint { font-size: .79rem; color: var(--muted); margin-top: 6px; }
.field-hint code { background: var(--bg); padding: 1px 6px; border-radius: 5px; }
.checkbox-field { display: flex; align-items: center; gap: 10px; font-size: .9rem; font-weight: 600; color: var(--ink-soft); margin-bottom: 16px; cursor: pointer; }
.checkbox-field input { width: 17px; height: 17px; accent-color: var(--accent); }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--ink); color: #cfc9bc;
  display: flex; flex-direction: column; padding: 22px 14px;
  position: sticky; top: 0; height: 100vh;
}
.logo-side { color: #fff; padding: 6px 12px 22px; display: block; }
.side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.side-link {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: .93rem; color: #cfc9bc; transition: .2s ease;
}
.side-link svg { width: 19px; height: 19px; flex-shrink: 0; }
.side-link:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.side-link.active { background: var(--accent); color: #fff; }
.side-badge {
  margin-left: auto; background: #fff; color: var(--ink);
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  font-size: .72rem; font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.side-foot { display: flex; flex-direction: column; gap: 4px; border-top: 1px solid rgba(255,255,255,.12); padding-top: 12px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  background: rgba(244, 242, 236, .9); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 14px 28px; position: sticky; top: 0; z-index: 40;
}
.topbar h1 { font-size: 1.25rem; font-weight: 800; }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: .92rem; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--ink); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: .9rem;
}
.sidebar-toggle { display: none; }
.content { padding: 28px; }

/* ---------- Dashboard ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-md); }
.stat-label { font-size: .82rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.stat-value { font-size: 2rem; font-weight: 800; margin-top: 6px; letter-spacing: -.02em; }
.two-col { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; align-items: start; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-md); margin-bottom: 22px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 22px 14px; flex-wrap: wrap; }
.panel-head h2 { font-size: 1.05rem; font-weight: 800; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; padding: 0 10px 14px; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th {
  text-align: left; font-size: .72rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #faf9f5; }
.th-actions { text-align: right; }
.td-actions { text-align: right; white-space: nowrap; }
.td-actions .mini-btn { margin-left: 6px; }
.mini-btn {
  padding: 7px 13px; border-radius: 999px; font-size: .78rem; font-weight: 700;
  border: 1px solid var(--line); background: #fff; color: var(--ink-soft); transition: .15s ease;
}
.mini-btn:hover { border-color: var(--ink); color: var(--ink); }
.mini-btn.danger { color: var(--red); border-color: #f3c9c9; }
.mini-btn.danger:hover { background: var(--red); border-color: var(--red); color: #fff; }

.thumb { width: 46px; height: 46px; border-radius: var(--radius-sm); object-fit: cover; background: #eee; }
.cell-name { font-weight: 700; }
.cell-sub { font-size: .78rem; color: var(--muted); font-weight: 500; }
.price-cell { font-weight: 800; white-space: nowrap; }

.stock-pill { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: .85rem; }
.stock-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.stock-pill.low .stock-dot { background: var(--accent); }
.stock-pill.out .stock-dot { background: var(--red); }

.status-badge {
  display: inline-block; padding: 5px 12px; border-radius: 999px;
  font-size: .74rem; font-weight: 800; text-transform: capitalize;
}
.status-pending    { background: #fdf0d7; color: #92610a; }
.status-confirmed  { background: #e0edff; color: #1d55b8; }
.status-shipped    { background: #ede7fd; color: #5b3ec4; }
.status-delivered  { background: #dcf5e7; color: #157347; }
.status-cancelled  { background: #fde3e3; color: var(--red); }
.status-active     { background: #dcf5e7; color: #157347; }
.status-hidden     { background: #edeae2; color: #8a8474; }

.low-stock { list-style: none; padding: 4px 22px 20px; }
.low-stock li { display: flex; justify-content: space-between; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.low-stock li:last-child { border-bottom: none; }
.low-stock .ls-name { font-weight: 600; }
.low-stock .ls-qty { font-weight: 800; color: var(--accent); }
.low-stock .ok { color: var(--muted); font-size: .86rem; }

/* ---------- Inline forms / filters ---------- */
.inline-form { display: flex; gap: 10px; padding: 0 22px 18px; flex-wrap: wrap; }
.inline-form input {
  flex: 1; min-width: 200px; padding: 11px 15px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); outline: none; font-size: .94rem;
}
.inline-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.filter-pills { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 22px 16px; }
.pill {
  padding: 7px 16px; border-radius: 999px; background: var(--bg);
  border: 1px solid var(--line); font-weight: 600; font-size: .84rem; color: var(--ink-soft); transition: .2s ease;
}
.pill:hover { border-color: var(--accent); color: var(--accent); }
.pill.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.select-sm { padding: 9px 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-weight: 600; font-size: .85rem; outline: none; cursor: pointer; }

.empty-row td { text-align: center; color: var(--muted); padding: 34px 12px; }

/* ---------- Modals ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 18px; background: rgba(15, 13, 9, .5); backdrop-filter: blur(3px); }
.modal-card {
  position: relative; background: var(--card); border-radius: 18px; width: 100%; max-width: 620px;
  padding: 30px 28px; box-shadow: var(--shadow-lg); max-height: calc(100vh - 40px); overflow-y: auto;
  animation: pop .25s ease;
}
@keyframes pop { from { transform: scale(.96) translateY(10px); opacity: 0; } }
.modal-close { position: absolute; top: 12px; right: 12px; z-index: 5; background: var(--bg); }
.modal-title { font-size: 1.3rem; font-weight: 800; margin-bottom: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* Order detail */
.od-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 22px; margin-bottom: 18px; font-size: .9rem; }
.od-grid dt { font-size: .74rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.od-grid dd { font-weight: 600; margin-bottom: 6px; word-break: break-word; }
.od-items { width: 100%; border-collapse: collapse; font-size: .88rem; margin-bottom: 18px; }
.od-items th { text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--line); font-size: .74rem; text-transform: uppercase; color: var(--muted); }
.od-items td { padding: 8px 10px; border-bottom: 1px solid var(--line); }
.od-items .num { text-align: right; }
.od-total { display: flex; justify-content: space-between; font-weight: 800; font-size: 1.05rem; margin-bottom: 20px; }
.status-update { border-top: 1px solid var(--line); padding-top: 18px; }
.status-update label { display: block; font-size: .83rem; font-weight: 700; margin-bottom: 8px; }
.status-update-row { display: flex; gap: 10px; }
.status-update-row select {
  flex: 1; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; outline: none; font-size: .92rem;
}

/* ---------- Toasts ---------- */
.toast-wrap { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 130; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 999px;
  font-size: .88rem; font-weight: 600; box-shadow: var(--shadow-lg);
  animation: toast-in .25s ease; max-width: 92vw; text-align: center;
}
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
.toast.leaving { animation: toast-out .3s ease forwards; }
@keyframes toast-in { from { transform: translateY(14px); opacity: 0; } }
@keyframes toast-out { to { transform: translateY(14px); opacity: 0; } }

/* ---------- Appearance ---------- */
.panel-note { color: var(--muted); font-size: .92rem; margin: -4px 0 20px; max-width: 620px; }
.appearance-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 24px; max-width: 720px; }
.color-row { display: flex; align-items: center; gap: 12px; }
.color-row input[type="color"] {
  width: 56px; height: 42px; padding: 4px; border: 1px solid var(--line);
  border-radius: 9px; background: #fff; cursor: pointer; flex: none;
}
.color-row code { font-size: .88rem; color: var(--ink-soft); background: var(--bg); padding: 4px 9px; border-radius: 6px; }
.appearance-preview {
  max-width: 720px; margin: 20px 0 18px; border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-md);
}
.preview-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 15px 18px; transition: background .2s ease; }
.preview-logo { font-weight: 800; letter-spacing: .05em; font-size: .8rem; color: var(--ink); }
.preview-logo span { color: var(--accent); }
.preview-nav { display: flex; gap: 16px; font-size: .78rem; font-weight: 600; transition: color .2s ease; flex-wrap: wrap; }
.preview-nav em { font-style: normal; }
.preview-footer { display: flex; flex-direction: column; gap: 4px; padding: 18px; font-size: .78rem; transition: background .2s ease, color .2s ease; }
.preview-footer strong { font-size: .82rem; letter-spacing: .05em; }
.appearance-actions { display: flex; gap: 10px; justify-content: flex-end; max-width: 720px; flex-wrap: wrap; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 90;
    transform: translateX(-105%); transition: transform .28s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .sidebar-toggle { display: inline-flex; }
  .content { padding: 18px 14px; }
  .topbar { padding: 12px 16px; }
}

@media (max-width: 560px) {
  .appearance-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 16px; }
  .stat-value { font-size: 1.5rem; }
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .modal-card { padding: 24px 18px; }
  .od-grid { grid-template-columns: 1fr; }
  .login-card { padding: 30px 22px; }
}

/* ---------- Messages ---------- */
.panel-count { font-size: .82rem; font-weight: 700; color: var(--muted); }
.msg-from { color: var(--accent); font-weight: 600; }
.msg-from:hover { text-decoration: underline; }
.msg-subject { font-weight: 700; min-width: 140px; }
.msg-text { min-width: 260px; max-width: 460px; color: var(--ink-soft); white-space: normal; word-break: break-word; }
.panel-note { padding: 0 22px; }
#appearanceForm { padding: 0 22px 22px; }

@media (max-width: 560px) {
  .panel-note, #appearanceForm { padding-inline: 16px; }
}

/* ---------- Appearance: layouts + product categories ---------- */
.appearance-section {
  font-size: .74rem; font-weight: 800; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted); margin: 20px 0 10px;
}
.appearance-section:first-of-type { margin-top: 0; }
.design-select {
  width: 100%; padding: 11px 14px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: #fff;
  font-weight: 600; font-size: .9rem; outline: none; cursor: pointer;
}
.design-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.checkbox-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px;
  max-height: 180px; overflow-y: auto;
}
.checkbox-grid label {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: .92rem; cursor: pointer;
}
.checkbox-grid input { width: 16px; height: 16px; accent-color: var(--accent); flex: none; }

/* Preview variants for the selected header/footer design */
.preview-header--centered { flex-direction: column; gap: 6px; }
.preview-header--centered .preview-nav { justify-content: center; }
.preview-header--minimal { background: transparent !important; }
.preview-header--minimal .preview-nav em { text-transform: uppercase; letter-spacing: .09em; font-size: .7rem; }
.preview-header--floating {
  border: 1px solid var(--line); border-radius: 999px;
  margin: 10px 12px 0; padding: 10px 14px; box-shadow: 0 4px 12px rgba(23,21,15,.10);
}
.preview-footer--centered { align-items: center; text-align: center; }
.preview-footer--compact { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
.preview-footer--compact strong { margin-right: 4px; }
.preview-footer--cards {
  border: 1px solid rgba(255, 255, 255, .18); border-radius: 10px;
  margin: 10px; padding: 14px; background: rgba(255, 255, 255, .06);
}

@media (max-width: 560px) {
  .checkbox-grid { grid-template-columns: 1fr; }
}
