/* ==========================================================================
   WONDERS KIDS — COMMON.CSS
   Shared design tokens + base components for the ENTIRE site/admin panel.

   Everything below is driven by the palette in :root. Change a value here
   and it updates everywhere the variable is used — today across this file
   and login.css, and later across every other admin/site screen.

   When the palette becomes dynamic (pulled from DB/settings), these same
   custom-property names can simply be echoed out by PHP into an inline
   <style> block or a generated CSS file — no selectors need to change.
   ========================================================================== */

:root {

  /* ---------------------------------------------------------------------
     1. BRAND — CORE (from the site's navy header + indigo search button)
     --------------------------------------------------------------------- */
  --wk-navy-900: #12123a;   /* darkest navy   — top utility bar, headings */
  --wk-navy-800: #1b1b4b;   /* aside panels, hover of navy-900            */
  --wk-navy-700: #2a2a63;   /* gradients, secondary dark surfaces         */
  --wk-navy-600: #3d3d84;   /* borders/text on dark surfaces              */

  --wk-indigo-600: #4a4fd6; /* primary hover / pressed                    */
  --wk-indigo-500: #5b5fef; /* PRIMARY brand action — buttons, links      */
  --wk-indigo-400: #8285f4; /* lighter accent, icon strokes on dark bg    */
  --wk-indigo-100: #e9e9fd; /* tint backgrounds, focus rings              */

  /* ---------------------------------------------------------------------
     2. BRAND — ACCENTS (lifted from the hero doodles + "kids" wordmark)
     --------------------------------------------------------------------- */
  --wk-teal-400:   #4fc3c3;  /* hot-air balloon                           */
  --wk-coral-500:  #f2694b;  /* paper plane                               */
  --wk-yellow-400: #f4b740;  /* sun / flower                              */
  --wk-green-500:  #4caf50;  /* logo letter "k"                           */
  --wk-red-500:    #e6485a;  /* logo letter "i"                           */
  --wk-blue-500:   #2f6fed;  /* logo letter "d"                           */
  --wk-violet-500: #8b5cf6;  /* logo letter "s"                           */

  /* ---------------------------------------------------------------------
     3. NEUTRALS
     --------------------------------------------------------------------- */
  --wk-white:    #ffffff;
  --wk-gray-50:  #f6f6fb;   /* page background (matches hero bg)          */
  --wk-gray-100: #eeeef4;
  --wk-gray-200: #e1e1ea;
  --wk-gray-300: #c9c9d6;
  --wk-gray-400: #9d9db1;
  --wk-gray-600: #6a6a80;   /* body copy                                  */
  --wk-gray-800: #34344a;

  /* ---------------------------------------------------------------------
     4. SEMANTIC ALIASES — reference these in components, not raw colors
     --------------------------------------------------------------------- */
  --color-bg-page:       var(--wk-gray-50);
  --color-bg-surface:    var(--wk-white);
  --color-bg-inverse:    var(--wk-navy-900);

  --color-text-heading:  var(--wk-navy-900);
  --color-text-body:     var(--wk-gray-600);
  --color-text-muted:    var(--wk-gray-400);
  --color-text-inverse:  var(--wk-white);

  --color-border:        var(--wk-gray-200);
  --color-border-strong: var(--wk-gray-300);

  --color-primary:       var(--wk-indigo-500);
  --color-primary-hover: var(--wk-indigo-600);
  --color-primary-soft:  var(--wk-indigo-100);

  --color-success: var(--wk-green-500);
  --color-danger:  var(--wk-red-500);
  --color-warning: var(--wk-yellow-400);
  --color-info:    var(--wk-teal-400);

  /* ---------------------------------------------------------------------
     5. TYPOGRAPHY
     --------------------------------------------------------------------- */
  --font-display: 'Baloo 2', 'Segoe UI', system-ui, sans-serif; /* headings/wordmark */
  --font-body:    'Inter', 'Segoe UI', system-ui, sans-serif;   /* UI / body / forms */

  /* ---------------------------------------------------------------------
     6. RADIUS / SHADOW / SPACING
     --------------------------------------------------------------------- */
  --radius-sm:   8px;
  --radius-md:   14px;
  --radius-lg:   22px;
  --radius-pill: 999px;

  --shadow-sm: 0 2px 8px rgba(18, 18, 58, .06);
  --shadow-md: 0 12px 32px rgba(18, 18, 58, .10);
  --shadow-lg: 0 24px 60px rgba(18, 18, 58, .18);

  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px; --space-8: 64px;

  --ease-out: cubic-bezier(.16, 1, .3, 1);

  /* ---------------------------------------------------------------------
     7. APP SHELL (sidebar + topbar) — shared by every logged-in admin page
     --------------------------------------------------------------------- */
  --sidebar-width:           264px;
  --sidebar-width-collapsed: 84px;
  --topbar-height:           72px;

  --color-sidebar-bg-start: var(--wk-navy-900);
  --color-sidebar-bg-end:   var(--wk-navy-800);
  --color-sidebar-border:   rgba(255, 255, 255, .08);
  --color-sidebar-text:     rgba(255, 255, 255, .64);
  --color-sidebar-text-hi:  rgba(255, 255, 255, .92);
  --color-sidebar-hover-bg: rgba(255, 255, 255, .06);
  --color-sidebar-active-bg:   rgba(91, 95, 239, .22);
  --color-sidebar-active-text: #ffffff;
  --color-sidebar-active-bar:  var(--wk-indigo-400);
}

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

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

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--color-text-body);
  background: var(--color-bg-page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img { max-width: 100%; display: block; }

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

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--color-text-heading);
  margin: 0 0 var(--space-3);
  line-height: 1.2;
}

p { margin: 0 0 var(--space-3); }

button { font-family: inherit; }

/* Visible, on-brand keyboard focus everywhere */
a:focus-visible,
button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--wk-indigo-400);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* ==========================================================================
   COMMON COMPONENTS — reused across login.css and future admin screens
   ========================================================================== */

/* --- Surface card ------------------------------------------------------- */
.card {
  background: var(--color-bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* --- Buttons -------------------------------------------------------------*/
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  padding: 13px 24px;
  border-radius: var(--radius-md);
  transition: transform .18s var(--ease-out), box-shadow .18s var(--ease-out), background .18s var(--ease-out);
}

.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-sm svg { width: 15px; height: 15px; }

.btn-primary {
  color: var(--color-text-inverse);
  background: linear-gradient(135deg, var(--wk-indigo-500), var(--wk-indigo-600));
  box-shadow: 0 10px 24px rgba(91, 95, 239, .35);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(91, 95, 239, .42);
}

.btn-primary:active { transform: translateY(0); }

.btn-primary:disabled {
  opacity: .6;
  cursor: not-allowed;
  transform: none;
}

.btn-ghost {
  color: var(--color-text-body);
  background: var(--wk-gray-100);
}
.btn-ghost:hover { background: var(--wk-gray-200); color: var(--color-text-heading); }

.btn-danger-ghost {
  color: var(--wk-red-500);
  background: #fdeceb;
}
.btn-danger-ghost:hover { background: #fbd9d6; }

.btn-icon {
  padding: 9px;
  border-radius: var(--radius-sm);
}

/* --- Row action buttons (edit/delete/etc. on table & tree rows) ---------- */
.row-action-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background .15s var(--ease-out), color .15s var(--ease-out), transform .15s var(--ease-out);
}
.row-action-btn svg { width: 15px; height: 15px; }

.row-action-btn:hover {
  background: var(--wk-indigo-100);
  color: var(--wk-indigo-600);
  transform: translateY(-1px);
}
.row-action-btn:active { transform: translateY(0); }

.row-action-btn:focus-visible {
  outline: 2px solid var(--wk-indigo-400);
  outline-offset: 2px;
}

/* Semantic tints for specific actions — apply alongside the base class */
.row-action-btn.is-success:hover { background: #e7f6ea; color: var(--wk-green-500); }
.row-action-btn.is-danger:hover  { background: #fdeceb; color: var(--wk-red-500); }

/* --- Form fields ---------------------------------------------------------*/
.form-group { margin-bottom: var(--space-5); }

.form-label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--color-text-heading);
  margin-bottom: var(--space-2);
}

.form-control {
  width: 100%;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--color-text-heading);
  background: var(--wk-gray-50);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 13px 16px;
  transition: border-color .16s var(--ease-out), background .16s var(--ease-out), box-shadow .16s var(--ease-out);
}

.form-control::placeholder { color: var(--color-text-muted); }

.form-control:focus {
  outline: none;
  background: var(--color-bg-surface);
  border-color: var(--wk-indigo-400);
  box-shadow: 0 0 0 4px var(--color-primary-soft);
}

.form-hint {
  font-size: 12.5px;
  color: var(--color-text-muted);
  margin-top: 6px;
}

/* Lay two fields side by side; stacks automatically if you nest form-groups */
.form-row { display: flex; gap: 14px; }
.form-row > .form-group { flex: 1; min-width: 0; }

/* --- Input with a fixed prefix/suffix symbol (₹, %, etc.) ---------------- */
.input-affix { position: relative; }
.input-affix .form-control { padding-left: 30px; }
.input-affix-symbol {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  font-size: 14px;
  font-weight: 600;
  pointer-events: none;
}
.input-affix--suffix .form-control { padding-left: 16px; padding-right: 34px; }
.input-affix--suffix .input-affix-symbol { left: auto; right: 14px; }

/* --- Segmented control (radio buttons styled as a toggle group) --------- */
.segmented {
  position: relative;
  display: inline-flex;
  background: var(--wk-gray-100);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 4px;
}
.segmented.segmented-block { display: flex; width: 100%; }

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented label {
  padding: 9px 16px;
  border-radius: calc(var(--radius-md) - 4px);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--color-text-body);
  cursor: pointer;
  text-align: center;
  transition: background .15s var(--ease-out), color .15s var(--ease-out), box-shadow .15s var(--ease-out);
}
.segmented.segmented-block label { flex: 1; }

.segmented input:checked + label {
  background: var(--color-bg-surface);
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

.segmented input:focus-visible + label {
  outline: 2px solid var(--wk-indigo-400);
  outline-offset: 1px;
}

/* --- Toggle switch (on/off, e.g. coupon Active status) ------------------- */
.toggle-switch {
  position: relative;
  display: inline-flex;
  width: 42px;
  height: 25px;
  flex-shrink: 0;
}
.toggle-switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}
.toggle-switch-track {
  position: absolute;
  inset: 0;
  background: var(--wk-gray-300);
  border-radius: var(--radius-pill);
  transition: background .18s var(--ease-out);
}
.toggle-switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 19px;
  height: 19px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .18s var(--ease-out);
}
.toggle-switch input:checked ~ .toggle-switch-track { background: var(--color-primary); }
.toggle-switch input:checked ~ .toggle-switch-thumb { transform: translateX(17px); }
.toggle-switch input:focus-visible ~ .toggle-switch-track {
  outline: 2px solid var(--wk-indigo-400);
  outline-offset: 2px;
}

/* --- Checkbox list row (e.g. picking specific courses) ------------------- */
.check-list {
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  max-height: 220px;
  overflow-y: auto;
}
.check-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--wk-gray-100);
  cursor: pointer;
}
.check-list-item:last-child { border-bottom: none; }
.check-list-item:hover { background: var(--wk-gray-50); }
.check-list-item input { width: 16px; height: 16px; accent-color: var(--color-primary); cursor: pointer; flex-shrink: 0; }
.check-list-item-name { font-size: 13.5px; font-weight: 600; color: var(--color-text-heading); }
.check-list-item-meta { font-size: 12px; color: var(--color-text-muted); }

/* --- Generic form element polish (select arrow, textarea sizing) --------- */
textarea.form-control { min-height: 90px; resize: vertical; }

select.form-control {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239d9db1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  padding-right: 38px;
  cursor: pointer;
}
select.form-control option:disabled { color: var(--color-text-muted); }

/* --- Image upload dropzone (thumbnails, cover images, etc.) -------------- */
.image-upload {
  border: 1.5px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  padding: 20px;
  transition: border-color .15s var(--ease-out), background .15s var(--ease-out);
}
.image-upload:hover,
.image-upload.is-dragover {
  border-color: var(--wk-indigo-400);
  background: var(--wk-indigo-100);
}

.image-upload-empty svg { width: 26px; height: 26px; color: var(--color-text-muted); margin: 0 auto 10px; }
.image-upload-empty p { margin: 0 0 4px; font-size: 13.5px; color: var(--color-text-body); }
.image-upload-empty .link-text { color: var(--color-primary); font-weight: 600; }

.image-upload-preview { position: relative; width: 100%; }
.image-upload-preview img {
  max-height: 160px;
  margin: 0 auto;
  border-radius: var(--radius-sm);
  display: block;
}
.image-upload-remove {
  position: absolute;
  top: -10px;
  right: calc(50% - 90px);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--wk-red-500);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  cursor: pointer;
}
.image-upload-remove svg { width: 14px; height: 14px; }

/* ==========================================================================
   DRAWER — right-side slide-over used for Add/Edit forms across the panel
   ========================================================================== */
.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(18, 18, 58, .5);
  z-index: 60;
}
.drawer-overlay.is-open { display: block; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 520px;
  max-width: 100vw;
  background: var(--color-bg-surface);
  box-shadow: var(--shadow-lg);
  z-index: 61;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .28s var(--ease-out);
}
.drawer.is-open { transform: translateX(0); }

.drawer--narrow { width: 400px; }
.drawer--wide { width: 720px; }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.drawer-head h2 { font-size: 18px; margin: 0; }

.drawer-close {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  flex-shrink: 0;
}
.drawer-close:hover { background: var(--wk-gray-100); color: var(--color-text-heading); }

.drawer-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px;
}

.drawer-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

@media (max-width: 560px) {
  .drawer { width: 100vw; }
  .form-row { flex-direction: column; gap: 0; }
}

/* --- Badges / pills --------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
}

.badge-soft-indigo { background: var(--wk-indigo-100); color: var(--wk-indigo-600); }

/* --- Alerts ------------------------------------------------------------ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  font-size: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-5);
}

.alert-danger {
  background: #fdeceb;
  color: #b3271e;
  border: 1px solid #f6c9c4;
}

.is-hidden { display: none !important; }