/* ==========================================================================
   DESMART ADMIN PANEL — matches the website's brand (magenta + gold)
   ========================================================================== */
:root {
  --primary: #9f0656;
  --primary-dark: #690a3c;
  --primary-light: #d6127f;
  --gold: #c9a227;
  --blush: #fdf1f6;
  --bg: #faf5f8;
  --white: #ffffff;
  --ink: #2b0a1d;
  --ink-soft: #7a5a6b;
  --border: #f0d9e6;
  --wa: #1fa855;
  --wa-dark: #178a45;
  --radius: 14px;
  --shadow: 0 10px 30px -18px rgba(105, 10, 60, 0.28);
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Work Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { font-family: var(--font-display); margin: 0 0 0.3rem; line-height: 1.15; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.25rem; }
p { margin: 0 0 0.75rem; }
button { font-family: inherit; cursor: pointer; }
a { color: inherit; }
code { background: var(--blush); border: 1px solid var(--border); border-radius: 5px; padding: 0 0.3rem; font-size: 0.85em; }
.muted { color: var(--ink-soft); }
.hint { font-size: 0.82rem; color: var(--ink-soft); }

:focus-visible { outline: 2px solid var(--primary-light); outline-offset: 2px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  padding: 0.6rem 1.1rem; border-radius: 999px; border: 1.5px solid transparent;
  font-weight: 600; font-size: 0.9rem; text-decoration: none; white-space: nowrap;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}
.btn:hover { transform: translateY(-1px); }
.btn[disabled] { opacity: 0.6; cursor: progress; transform: none; }
.btn-block { width: 100%; }
.btn-primary { background: linear-gradient(135deg, var(--primary-light), var(--primary)); color: #fff; box-shadow: 0 8px 20px -10px rgba(159, 6, 86, 0.6); }
.btn-soft { background: var(--white); color: var(--primary); border-color: var(--border); }
.btn-soft:hover { border-color: var(--primary); }
.btn-wa { background: var(--wa); color: #fff; }
.btn-wa:hover { background: var(--wa-dark); }
.btn-danger { background: var(--white); color: #b3002e; border-color: #f2c4cf; }
.btn-danger:hover { background: #fdecef; }
.btn-sm { padding: 0.42rem 0.85rem; font-size: 0.82rem; }
.btn svg { width: 16px; height: 16px; }

/* ---------- Forms ---------- */
.field { display: block; margin-bottom: 1rem; }
.field > span { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.3rem; }
.field em { font-weight: 400; font-style: normal; color: var(--ink-soft); }
input[type="text"], input[type="password"], input[type="tel"], input[type="search"], select, textarea {
  width: 100%; padding: 0.7rem 0.85rem; font: inherit; color: var(--ink);
  background: var(--white); border: 1.5px solid var(--border); border-radius: 10px;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: none; }
textarea { resize: vertical; }
.two { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; }

.alert { border-radius: 10px; padding: 0.7rem 0.95rem; font-size: 0.9rem; margin-bottom: 1rem; }
.alert-error { background: #fdecef; border: 1px solid #f5b8c4; color: #8f0024; }
.alert-warn { background: #fff6dc; border: 1px solid #ecd48a; color: #6b4b00; }

/* ---------- Login ---------- */
.login-view { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: radial-gradient(circle at 20% 10%, #f8d7e8 0, transparent 45%), var(--bg); }
.login-card { width: 100%; max-width: 400px; background: var(--white); border: 1px solid var(--border); border-radius: 24px; padding: 2rem; box-shadow: var(--shadow); text-align: left; }
.login-logo { height: 64px; width: auto; margin: 0 auto 1rem; display: block; }
.login-card h1 { text-align: center; font-size: 1.6rem; }
.login-card > .muted { text-align: center; font-size: 0.9rem; margin-bottom: 1.25rem; }
.back-link { display: block; text-align: center; margin-top: 1rem; font-size: 0.85rem; color: var(--ink-soft); text-decoration: none; }
.back-link:hover { color: var(--primary); }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--primary-dark), #4a0729);
  color: #fff; padding: 1.25rem 1rem;
}
.sidebar-brand { display: flex; align-items: center; gap: 0.6rem; padding: 0.25rem 0.5rem 1.25rem; }
.sidebar-brand img { height: 44px; width: auto; background: #fff; border-radius: 10px; padding: 3px; }
.sidebar-brand span { font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; letter-spacing: 0.02em; }

.sidebar-nav { display: flex; flex-direction: column; gap: 0.25rem; }
.nav-item {
  display: flex; align-items: center; gap: 0.7rem; width: 100%;
  padding: 0.75rem 0.85rem; border: none; border-radius: 12px; background: transparent;
  color: rgba(255, 255, 255, 0.78); font-size: 0.95rem; font-weight: 500; text-align: left;
}
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.nav-item.is-active { background: rgba(255, 255, 255, 0.16); color: #fff; font-weight: 600; }
.nav-item[disabled] { opacity: 0.35; cursor: not-allowed; }
.nav-badge { margin-left: auto; background: var(--gold); color: var(--primary-dark); font-size: 0.75rem; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; display: grid; place-items: center; }

.sidebar-foot { margin-top: auto; display: grid; gap: 0.6rem; }
.foot-link { color: rgba(255, 255, 255, 0.75); font-size: 0.85rem; text-decoration: none; padding: 0 0.5rem; }
.foot-link:hover { color: #fff; }
.who { padding: 0 0.5rem; font-size: 0.82rem; color: rgba(255, 255, 255, 0.6); }
.who span { color: #fff; font-weight: 600; }
.sidebar .btn-soft { background: rgba(255, 255, 255, 0.1); color: #fff; border-color: rgba(255, 255, 255, 0.25); }
.sidebar .btn-soft:hover { background: rgba(255, 255, 255, 0.2); }

.content { padding: 2rem clamp(1rem, 3vw, 2.5rem) 4rem; max-width: 1200px; width: 100%; }
.head-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.view-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.9rem; margin-bottom: 1.5rem; }
.stat { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.stat b { display: block; font-family: var(--font-display); font-size: 2rem; line-height: 1.1; color: var(--primary); }
.stat span { font-size: 0.82rem; color: var(--ink-soft); }
.stat--pending { border-color: #ecd48a; background: #fffaf0; }
.stat--pending b { color: #8a5a00; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; gap: 0.75rem 1rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar-right { display: flex; gap: 0.6rem; margin-left: auto; flex-wrap: wrap; }
.search { min-width: 260px; }
.select { width: auto; }

.tabs { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.tab {
  border: 1.5px solid var(--border); background: var(--white); color: var(--ink-soft);
  padding: 0.45rem 0.85rem; border-radius: 999px; font-size: 0.85rem; font-weight: 600;
}
.tab:hover { border-color: var(--primary); color: var(--primary); }
.tab.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.tab i { font-style: normal; opacity: 0.75; margin-left: 0.25rem; font-weight: 500; }

/* ---------- Appointment rows ---------- */
.list { display: grid; gap: 0.75rem; }
.empty { text-align: center; padding: 3rem 1rem; background: var(--white); border: 1.5px dashed var(--border); border-radius: var(--radius); color: var(--ink-soft); }

.appt {
  display: grid; grid-template-columns: 110px 1fr auto; gap: 1rem 1.25rem; align-items: start;
  background: var(--white); border: 1px solid var(--border); border-left: 5px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.15rem; box-shadow: var(--shadow);
}
.appt--pending { border-left-color: #e0a100; }
.appt--confirmed { border-left-color: var(--wa); }
.appt--completed { border-left-color: #5b5bd6; }
.appt--cancelled { border-left-color: #c9c9c9; opacity: 0.78; }

.appt-when { text-align: center; background: var(--blush); border-radius: 12px; padding: 0.6rem 0.4rem; }
.appt-day { display: block; font-weight: 700; font-size: 0.95rem; }
.appt-time { display: block; color: var(--primary); font-weight: 600; font-size: 0.9rem; }
.appt-today { display: inline-block; margin-top: 0.25rem; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; background: var(--primary); color: #fff; border-radius: 999px; padding: 0.05rem 0.5rem; }

.appt-name { font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; flex-wrap: wrap; gap: 0.4rem; }
.appt-ref { font-size: 0.75rem; font-weight: 500; color: var(--ink-soft); }
.appt-service { color: var(--primary); font-weight: 600; font-size: 0.92rem; margin-top: 0.1rem; }
.appt-contact { font-size: 0.88rem; color: var(--ink-soft); margin-top: 0.2rem; word-break: break-word; }
.appt-contact a { color: inherit; }
.appt-notes { margin-top: 0.4rem; font-size: 0.88rem; background: #fbf7f9; border-radius: 8px; padding: 0.4rem 0.6rem; white-space: pre-wrap; word-break: break-word; }
.appt-warn { margin-top: 0.4rem; font-size: 0.82rem; color: #8a5a00; font-weight: 600; }
.appt-meta { margin-top: 0.35rem; font-size: 0.76rem; color: var(--ink-soft); }

.appt-side { display: flex; flex-direction: column; align-items: flex-end; gap: 0.6rem; }
.appt-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: flex-end; }

.tag { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; border-radius: 999px; padding: 0.1rem 0.5rem; }
.tag-member { background: #ffe9f3; color: var(--primary); }

.pill { font-size: 0.75rem; font-weight: 700; padding: 0.25rem 0.75rem; border-radius: 999px; text-transform: capitalize; }
.pill--pending { background: #fff3d6; color: #8a5a00; }
.pill--confirmed { background: #e0f6e9; color: #146c3a; }
.pill--completed { background: #e8e8f7; color: #3b3b8f; }
.pill--cancelled { background: #eee; color: #666; }

/* ---------- Customer rows ---------- */
.cust {
  display: grid; grid-template-columns: 1.3fr 1.6fr 1fr 0.7fr auto; gap: 0.75rem 1rem; align-items: center;
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.85rem 1.15rem; box-shadow: var(--shadow);
}
.cust-head { background: transparent; border: none; box-shadow: none; padding: 0 1.15rem; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); }
.cust-name { font-weight: 700; }
.cust-sub { font-size: 0.88rem; color: var(--ink-soft); word-break: break-word; }
.cust-actions { display: flex; gap: 0.4rem; justify-content: flex-end; }
.cust-label { display: none; }

/* ---------- Settings ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1.25rem; align-items: start; }
.card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.4rem; box-shadow: var(--shadow); }
.card > .muted { font-size: 0.9rem; margin-bottom: 1.1rem; }
.preview { background: #dcf8c6; color: #123; border-radius: 12px 12px 12px 2px; padding: 0.75rem 0.9rem; font-size: 0.88rem; white-space: pre-wrap; margin: 0.4rem 0 1.1rem; max-width: 440px; }
.api-status { margin-top: 1.1rem; padding: 0.8rem 0.95rem; border-radius: 10px; font-size: 0.85rem; background: var(--blush); border: 1px solid var(--border); }
.api-status.is-on { background: #e0f6e9; border-color: #b9e8c9; color: #146c3a; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 1rem; bottom: 1rem; display: grid; gap: 0.5rem; z-index: 50; max-width: min(380px, calc(100vw - 2rem)); }
.toast { background: var(--ink); color: #fff; padding: 0.75rem 1rem; border-radius: 12px; font-size: 0.9rem; box-shadow: 0 14px 30px -12px rgba(0, 0, 0, 0.45); animation: pop 200ms ease; }
.toast--ok { background: #146c3a; }
.toast--error { background: #8f0024; }
.toast--new { background: var(--primary); }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; align-items: center; gap: 0.5rem; padding: 0.55rem 0.75rem; overflow-x: auto; }
  .sidebar-brand { padding: 0; }
  .sidebar-brand span { display: none; }
  .sidebar-brand img { height: 34px; }
  .sidebar-nav { flex-direction: row; gap: 0.15rem; }
  .nav-item { width: auto; padding: 0.55rem 0.75rem; }
  .nav-item span { font-size: 0.85rem; }
  .sidebar-foot { margin: 0 0 0 auto; display: flex; align-items: center; gap: 0.5rem; }
  .foot-link, .who { display: none; }
  .sidebar .btn-block { width: auto; padding: 0.45rem 0.85rem; font-size: 0.82rem; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .search { min-width: 0; flex: 1 1 200px; }
  .toolbar-right { margin-left: 0; width: 100%; }
}

@media (max-width: 700px) {
  .appt { grid-template-columns: 1fr; }
  .appt-when { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0.8rem; text-align: left; }
  .appt-when > div { display: flex; gap: 0.6rem; align-items: baseline; }
  .appt-side { flex-direction: row-reverse; justify-content: space-between; align-items: center; flex-wrap: wrap; }
  .appt-actions { justify-content: flex-start; }
  .cust { grid-template-columns: 1fr auto; }
  .cust-head { display: none; }
  .cust-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .two { grid-template-columns: 1fr; }
  h1 { font-size: 1.6rem; }
}


/* ==========================================================================
   PAYMENTS, SERVICES, TEAM  (added with Stripe payments)
   ========================================================================== */
.nav-item[hidden] { display: none; }
.stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stats--small { grid-template-columns: repeat(auto-fit, minmax(200px, 260px)); }
.section-title { font-family: var(--font-display); font-size: 1.3rem; margin: 2.2rem 0 1rem; }
.card--wide { grid-column: span 1; }
.cards { grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); }

.pill--pay-unpaid { background: #fff3d6; color: #8a5a00; }
.pill--pay-deposit_paid { background: #e0eefc; color: #1b4f8f; }
.pill--pay-paid { background: #e0f6e9; color: #146c3a; }
.pill--pay-refunded { background: #eee; color: #666; }
.appt-money { font-size: 0.88rem; font-weight: 600; margin-top: 0.15rem; }

.rows { display: grid; gap: 0.6rem; }
.row-card, .edit-row {
  display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; flex-wrap: wrap;
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.8rem 1rem;
}
.row-card { box-shadow: var(--shadow); }
.row-main { display: grid; gap: 0.15rem; min-width: 0; }
.row-side, .row-actions { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.edit-row input[type="text"], .edit-row input[type="number"] {
  font: inherit; padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 8px; min-width: 0; background: #fff;
}
.edit-row > input[type="text"] { flex: 1 1 180px; }
.edit-row.is-off { opacity: 0.6; }
.price-wrap { display: flex; align-items: center; gap: 0.3rem; }
.price-wrap input { width: 6.5rem; }
.check { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1rem; font-size: 0.92rem; cursor: pointer; }
.check input { accent-color: var(--primary); width: 1.05rem; height: 1.05rem; }
.edit-row .check { margin-bottom: 0; }
.edit-row--simple > div:first-child { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.tag { background: #eee; color: #555; }

.secret-box { margin-top: 1rem; padding: 0.9rem 1rem; background: #fffaf0; border: 1px solid #ecd48a; border-radius: var(--radius); }
.secret-box code { display: block; margin: 0.5rem 0; padding: 0.55rem 0.7rem; background: #fff; border-radius: 8px; font-size: 1.1rem; letter-spacing: 0.04em; user-select: all; }
.secret-box[hidden] { display: none; }

@media (max-width: 720px) {
  .edit-row { align-items: stretch; }
  .row-actions { width: 100%; }
}
