/* =====================================================================
   Studio Management System — shared design system
   Hand-coded CSS, no framework. Mobile-first, responsive breakpoints at
   640px (tablet) and 1024px (desktop sidebar).
   ===================================================================== */

:root {
  /* JV Studio brand palette (mirrors the public site's --primary/--secondary/--space) */
  --color-primary: #4F46E5;
  --color-primary-dark: #4338CA;
  --color-primary-light: #EEF2FF;
  --color-brand-purple: #4B3F72;
  --color-brand-space: #0A1128;
  --color-success: #16a34a;
  --color-success-light: #dcfce7;
  --color-warning: #d97706;
  --color-warning-light: #fef3c7;
  --color-danger: #dc2626;
  --color-danger-light: #fee2e2;
  --color-info: #0891b2;
  --color-info-light: #cffafe;

  --color-bg: #f4f5f9;
  --color-surface: #ffffff;
  --color-border: #e5e7eb;
  --color-text: #1f2330;
  --color-text-muted: #6b7280;
  --color-sidebar-bg: #0A1128;
  --color-sidebar-text: #b7b9c9;
  --color-sidebar-active: #4B3F72;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.09);
  --sidebar-width: 240px;
  --topbar-height: 64px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #121218;
    --color-surface: #1b1b24;
    --color-border: #2e2e3a;
    --color-text: #e7e7ee;
    --color-text-muted: #9a9aac;
    --color-primary-light: #24274d;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--color-primary); text-decoration: none; }
h1, h2, h3, h4 { margin: 0 0 8px; font-weight: 600; }
p { margin: 0 0 8px; }

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

.sidebar {
  width: var(--sidebar-width);
  background: var(--color-sidebar-bg);
  color: var(--color-sidebar-text);
  flex-shrink: 0;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  overflow-y: auto;
  z-index: 40;
  transition: transform 0.2s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 20px 16px;
  font-weight: 700; font-size: 16px; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand .logo-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--color-primary); }
.sidebar-brand svg { color: var(--color-primary); flex-shrink: 0; }
.sidebar-nav { padding: 12px 8px; list-style: none; margin: 0; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: var(--color-sidebar-text);
  font-size: 13.5px;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar-nav a.active { background: var(--color-sidebar-active); color: #fff; }
.sidebar-nav .icon { width: 18px; text-align: center; }

.main-area { margin-left: var(--sidebar-width); flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 30;
}
.topbar-title { font-size: 18px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.menu-toggle { display: none; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--color-text); }

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

.notif-wrap { position: relative; }
.notif-bell {
  position: relative; cursor: pointer; font-size: 18px; background: none; border: none;
  padding: 4px; color: inherit; font-family: inherit; line-height: 1; border-radius: var(--radius-sm);
}
.notif-bell:hover { background: var(--color-bg); }
.notif-badge {
  position: absolute; top: -4px; right: -6px; background: var(--color-danger); color: #fff;
  font-size: 10px; min-width: 16px; height: 16px; border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.notif-dropdown {
  display: none; position: absolute; top: calc(100% + 10px); right: -8px; width: 320px; max-height: 420px;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-md); z-index: 60; overflow: hidden; flex-direction: column;
}
.notif-dropdown.open { display: flex; }
.notif-dropdown-header {
  display: flex; align-items: center; justify-content: space-between; padding: 12px 14px;
  border-bottom: 1px solid var(--color-border); font-weight: 600; font-size: 13.5px;
}
.notif-mark-all {
  background: none; border: none; color: var(--color-primary); font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit; padding: 0;
}
.notif-dropdown-body { overflow-y: auto; flex: 1; }
.notif-item { padding: 10px 14px; border-bottom: 1px solid var(--color-border); cursor: pointer; }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--color-bg); }
.notif-item.unread { background: var(--color-primary-light); }
.notif-item.unread .notif-item-title::before {
  content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--color-primary); margin-right: 6px;
}
.notif-item-title { font-size: 13px; font-weight: 600; }
.notif-item-message { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }
.notif-item-time { font-size: 10.5px; color: var(--color-text-muted); margin-top: 4px; }
.user-chip { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.avatar-circle {
  width: 32px; height: 32px; border-radius: 50%; background: var(--color-primary);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px;
}

/* ---------- Cards & grids ---------- */
.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); padding: 20px; }
.card-title { font-size: 14px; color: var(--color-text-muted); margin-bottom: 4px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { display: flex; flex-direction: column; gap: 6px; }
.stat-value { font-size: 26px; font-weight: 700; }
.stat-icon { width: 40px; height: 40px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; font-size: 18px; margin-bottom: 4px; }
.bg-primary-soft { background: var(--color-primary-light); color: var(--color-primary); }
.bg-success-soft { background: var(--color-success-light); color: var(--color-success); }
.bg-warning-soft { background: var(--color-warning-light); color: var(--color-warning); }
.bg-info-soft { background: var(--color-info-light); color: var(--color-info); }

.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); }
table { width: 100%; border-collapse: collapse; min-width: 600px; }
thead th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--color-text-muted); padding: 12px 16px; border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--color-bg); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; text-transform: capitalize; }
.badge-pending, .badge-unpaid { background: var(--color-warning-light); color: var(--color-warning); }
.badge-confirmed, .badge-partial { background: var(--color-info-light); color: var(--color-info); }
.badge-completed, .badge-paid, .badge-active { background: var(--color-success-light); color: var(--color-success); }
.badge-cancelled, .badge-void, .badge-inactive { background: var(--color-danger-light); color: var(--color-danger); }
.badge-in_progress, .badge-sending { background: var(--color-primary-light); color: var(--color-primary); }
.badge-draft { background: var(--color-bg); color: var(--color-text-muted); }
.badge-failed { background: var(--color-danger-light); color: var(--color-danger); }

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 9px 16px; font-size: 13.5px; font-weight: 600; cursor: pointer;
  background: var(--color-surface); color: var(--color-text);
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-outline { background: transparent; border-color: var(--color-border); }
.btn-outline:hover { background: var(--color-bg); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-icon { padding: 6px 8px; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }

.form-group { margin-bottom: 14px; }
label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 13px; }
input, select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  background: var(--color-surface); color: var(--color-text); font-size: 13.5px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-light); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-error { color: var(--color-danger); font-size: 12px; margin-top: 4px; }
.help-text { color: var(--color-text-muted); font-size: 12px; margin-top: 4px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5);
  display: none; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 100; overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--color-surface); border-radius: var(--radius-lg); width: 100%; max-width: 560px;
  box-shadow: var(--shadow-md); animation: modal-in 0.15s ease;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--color-border); }
.modal-header h3 { margin: 0; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--color-text-muted); }
.modal-body { padding: 22px; max-height: 65vh; overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--color-border); }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; font-size: 13px; color: var(--color-text-muted); }
.pagination-controls { display: flex; gap: 6px; }

/* ---------- Toasts ---------- */
#toast-container { position: fixed; top: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--color-text); color: #fff; padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 13.5px; box-shadow: var(--shadow-md); min-width: 220px; animation: toast-in 0.2s ease;
}
.toast.success { background: var(--color-success); }
.toast.error { background: var(--color-danger); }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ---------- Login page ---------- */
/* ---------- Login: split-screen, JV Studio branded ---------- */
.login-shell { min-height: 100vh; display: flex; }

.login-visual {
  flex: 1 1 46%;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 64px;
  color: #fff;
  background: linear-gradient(160deg, var(--color-brand-space) 0%, var(--color-brand-purple) 100%);
}
.login-visual::before {
  content: '';
  position: absolute;
  width: 440px; height: 440px;
  border-radius: 50%;
  background: rgba(244, 91, 105, 0.22);
  top: -140px; right: -160px;
  filter: blur(6px);
}
.login-visual::after {
  content: '';
  position: absolute;
  width: 320px; height: 320px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  bottom: -120px; left: -90px;
}
.login-brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; font-size: 22px; font-weight: 700; margin-bottom: 28px; }
.login-brand svg { width: 30px; height: 30px; flex-shrink: 0; }
.login-tagline { position: relative; z-index: 1; font-size: 16px; line-height: 1.6; color: rgba(255, 255, 255, 0.78); max-width: 380px; margin-bottom: 44px; }
.login-feature-list { position: relative; z-index: 1; list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 18px; }
.login-feature-list li { display: flex; align-items: center; gap: 14px; font-size: 14px; color: rgba(255, 255, 255, 0.92); }
.login-feature-list .feature-icon {
  width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
  background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.14);
  display: flex; align-items: center; justify-content: center;
}
.login-feature-list svg { width: 18px; height: 18px; }

.login-form-panel { flex: 1 1 54%; display: flex; align-items: center; justify-content: center; padding: 40px 20px; background: var(--color-bg); }
.login-card { background: var(--color-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 44px; width: 100%; max-width: 400px; }
.login-logo { text-align: center; margin-bottom: 8px; }
.login-logo .logo-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--color-primary); display: inline-block; margin-right: 8px; }
.login-subtitle { text-align: center; color: var(--color-text-muted); font-size: 13.5px; margin-bottom: 28px; }
.login-error { background: var(--color-danger-light); color: var(--color-danger); padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 14px; display: none; }

@media (max-width: 1023px) {
  .login-visual { display: none; }
  .login-form-panel { background: linear-gradient(160deg, var(--color-brand-space) 0%, var(--color-brand-purple) 100%); }
}

/* ---------- Utilities ---------- */
.text-muted { color: var(--color-text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mb-0 { margin-bottom: 0; }
.mb-16 { margin-bottom: 16px; }
.mt-16 { margin-top: 16px; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.empty-state { text-align: center; padding: 48px 16px; color: var(--color-text-muted); }
.spinner { width: 22px; height: 22px; border: 3px solid var(--color-border); border-top-color: var(--color-primary); border-radius: 50%; animation: spin 0.7s linear infinite; margin: 24px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.thumb-card { border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--color-border); background: var(--color-surface); }
.thumb-card img { width: 100%; height: 140px; object-fit: cover; display: block; }
.thumb-card .thumb-meta { padding: 8px 10px; font-size: 12px; }

/* ---------- Recipient picker (campaigns) ---------- */
.picker-list { max-height: 200px; overflow-y: auto; border: 1px solid var(--color-border); border-radius: var(--radius-sm); margin-top: 6px; }
.picker-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--color-border); cursor: pointer; }
.picker-row:last-child { border-bottom: none; }
.picker-row:hover { background: var(--color-bg); }
.picker-row input[type="checkbox"] { width: auto; margin: 0; }
.picker-row .picker-meta { font-size: 12px; color: var(--color-text-muted); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--color-primary-light); color: var(--color-primary); border-radius: 999px; padding: 4px 6px 4px 10px; font-size: 12px; font-weight: 600; }
.chip button { background: none; border: none; color: inherit; cursor: pointer; font-size: 14px; line-height: 1; padding: 0 4px; }
.variable-row { display: flex; gap: 8px; margin-bottom: 6px; }
.variable-row input { flex: 1; }
.variable-row button { flex-shrink: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-area { margin-left: 0; }
  .menu-toggle { display: block; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .toolbar { flex-direction: column; align-items: stretch; }
}
