:root, :root[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-alt: #111827;
  --border: #334155;
  --border-subtle: #0f172a;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --input-bg: #0f172a;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --success-bg: #14532d;
  --success-text: #4ade80;
  --danger-bg: #450a0a;
  --danger-text: #f87171;
  --warning-bg: #451a03;
  --warning-text: #fb923c;
  --available-bg: #14532d33;
  --available-bg-hover: #14532d66;
  --booked-bg: #6366f1;
  --cancelled-bg: #45252533;
  --shadow: rgba(0, 0, 0, .4);
}

:root[data-theme="light"] {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --border: #e2e8f0;
  --border-subtle: #e5e7eb;
  --text: #0f172a;
  --text-muted: #475569;
  --text-faint: #94a3b8;
  --input-bg: #ffffff;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --success-bg: #dcfce7;
  --success-text: #15803d;
  --danger-bg: #fee2e2;
  --danger-text: #b91c1c;
  --warning-bg: #ffedd5;
  --warning-text: #c2410c;
  --available-bg: #dcfce799;
  --available-bg-hover: #bbf7d0;
  --booked-bg: #6366f1;
  --cancelled-bg: #fee2e299;
  --shadow: rgba(15, 23, 42, .12);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-alt: #f1f5f9;
    --border: #e2e8f0;
    --border-subtle: #e5e7eb;
    --text: #0f172a;
    --text-muted: #475569;
    --text-faint: #94a3b8;
    --input-bg: #ffffff;
    --success-bg: #dcfce7;
    --success-text: #15803d;
    --danger-bg: #fee2e2;
    --danger-text: #b91c1c;
    --warning-bg: #ffedd5;
    --warning-text: #c2410c;
    --available-bg: #dcfce799;
    --available-bg-hover: #bbf7d0;
    --cancelled-bg: #fee2e299;
    --shadow: rgba(15, 23, 42, .12);
  }
}

body { background: var(--bg); color: var(--text); }

@font-face {
  font-family: "IRANSans";
  src: url("fonts/IRANSansWeb_UltraLight.woff2") format("woff2"),
       url("fonts/IRANSansWeb_UltraLight.woff") format("woff");
  font-weight: 200;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IRANSans";
  src: url("fonts/IRANSansWeb_Light.woff2") format("woff2"),
       url("fonts/IRANSansWeb_Light.woff") format("woff");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IRANSans";
  src: url("fonts/IRANSansWeb.woff2") format("woff2"),
       url("fonts/IRANSansWeb.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IRANSans";
  src: url("fonts/IRANSansWeb_Medium.woff2") format("woff2"),
       url("fonts/IRANSansWeb_Medium.woff") format("woff");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IRANSans";
  src: url("fonts/IRANSansWeb_Bold.woff2") format("woff2"),
       url("fonts/IRANSansWeb_Bold.woff") format("woff");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

html[lang="fa"] body {
  font-family: "IRANSans", Tahoma, "Segoe UI", system-ui, sans-serif;
}

.theme-toggle {
  background: none; border: 1px solid var(--border); color: var(--text-muted);
  width: 34px; height: 34px; border-radius: 8px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1rem;
}
.theme-toggle:hover { color: var(--text); border-color: var(--text-muted); }

/* max-width:380px matches .login-panel-inner's own width (see login.css) -
   the email/password inputs above this button are width:100% of that same
   380px box, so this now renders exactly as wide as they are instead of
   the old fixed 320px cap, which made it visibly narrower than the rest of
   the form. margin:0 auto centers it under them by default; register.html
   sits in a wider page and already overrides this with its own inline
   margin/width where 380px wouldn't make sense centered in a 640px page. */
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  width: 100%; max-width: 380px; margin: 0 auto; padding: .65rem 1rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: .9rem; font-weight: 600; cursor: pointer; font-family: inherit;
}
.google-btn:hover { background: var(--surface-alt); }
.google-btn:disabled { opacity: .6; cursor: default; }
.google-btn.is-busy { cursor: wait; }

/* ---- Global button baseline (Bootstrap-ish) ----
   Applies to any plain <button>/submit via a single low-specificity
   attribute-less rule, so small action buttons scattered across
   admin/teacher tables get a consistent, modern look instead of the raw
   browser default. Kept to (0,0,1) specificity (bare "button") on purpose —
   any existing class-based button rule loaded after theme.css (admin.css,
   teacher.css, styles.css, home.css) overrides it automatically, so no
   :not() exclusion list is needed and can't get out of sync as new button
   classes are added. Opt out explicitly with .btn-plain if a bare <button>
   ever needs the browser default instead. */
button, input[type="submit"] {
  background: var(--primary); color: #fff; border: none; border-radius: 8px;
  padding: .5rem 1.05rem; font-size: .88rem; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: background .15s ease, transform .05s ease;
}
button:hover, input[type="submit"]:hover { background: var(--primary-hover); }
button:active, input[type="submit"]:active { transform: scale(.98); }
button:disabled { opacity: .55; cursor: not-allowed; }

.btn-plain, .btn-plain:hover, .btn-plain:active {
  background: none; color: inherit; border: none; border-radius: 0;
  padding: 0; font-weight: normal; transform: none;
}

/* ---- Global select baseline ----
   Native <select> renders with the OS's own chrome (no CSS controls its
   dropdown arrow color/shape directly), so it was the one form control still
   looking like a bare browser default everywhere. Applies to any select not
   opted out via .select-plain, same pattern as the button baseline above. */
select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background-color: var(--input-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: .5rem 2.1rem .5rem .75rem; font-size: .88rem; font-family: inherit;
  cursor: pointer; transition: border-color .15s ease;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .8rem center; background-size: 10px 6px;
}
html[dir="rtl"] select {
  padding: .5rem .75rem .5rem 2.1rem;
  background-position: left .8rem center;
}
select:hover { border-color: var(--text-muted); }
select:focus { outline: none; border-color: var(--primary); }
select:disabled { opacity: .55; cursor: not-allowed; }
select.select-plain { appearance: auto; -webkit-appearance: auto; background: none; border: none; padding: 0; }
select option { background: var(--surface); color: var(--text); }

/* Secondary/neutral action buttons (Cancel, Close, etc) — opt in via .btn-secondary */
button.btn-secondary, .btn-secondary {
  background: var(--surface-alt); color: var(--text); border: 1px solid var(--border);
}
button.btn-secondary:hover, .btn-secondary:hover { background: var(--border); }

/* Danger action buttons (Delete, Cancel session, etc) — opt in via .btn-danger */
button.btn-danger, .btn-danger {
  background: var(--danger-text); color: #fff;
}
button.btn-danger:hover, .btn-danger:hover { filter: brightness(1.08); }

/* ---- Toast notifications ---- */
#toastStack {
  position: fixed; top: 1rem; z-index: 9999;
  display: flex; flex-direction: column; gap: .6rem;
  max-width: min(360px, calc(100vw - 2rem));
}
html:not([dir="rtl"]) #toastStack { right: 1rem; }
html[dir="rtl"] #toastStack { left: 1rem; }

.toast {
  display: flex; align-items: flex-start; gap: .6rem;
  padding: .75rem .9rem; border-radius: 10px; box-shadow: 0 6px 20px var(--shadow);
  font-size: .88rem; line-height: 1.4; background: var(--surface); color: var(--text);
  border: 1px solid var(--border-subtle); border-left: 4px solid var(--primary);
  animation: toast-in .22s ease;
}
html[dir="rtl"] .toast { border-left: 1px solid var(--border-subtle); border-right: 4px solid var(--primary); }
.toast.toast-info { border-left-color: var(--primary); }
html[dir="rtl"] .toast.toast-info { border-right-color: var(--primary); }
.toast.toast-success { border-left-color: var(--success-text); }
html[dir="rtl"] .toast.toast-success { border-right-color: var(--success-text); }
.toast.toast-danger { border-left-color: var(--danger-text); }
html[dir="rtl"] .toast.toast-danger { border-right-color: var(--danger-text); }
.toast.toast-leaving { animation: toast-out .18s ease forwards; }

.toast-icon { flex-shrink: 0; font-weight: 700; }
.toast-message { flex: 1; word-break: break-word; }
.toast-close {
  background: none !important; border: none !important; color: var(--text-muted) !important;
  padding: 0 !important; font-size: 1rem !important; cursor: pointer; line-height: 1; flex-shrink: 0;
}
.toast-close:hover { color: var(--text) !important; }

@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-8px); } }

/* ---- Upload progress bar (see upload-progress.js) ---- */
.upload-progress-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; font-size: .82rem; color: var(--text-muted); margin-bottom: .3rem; }
.upload-progress-pct { font-weight: 600; color: var(--text); }
.upload-progress-track { height: 6px; border-radius: 999px; background: var(--border-subtle); overflow: hidden; }
.upload-progress-fill { height: 100%; background: var(--primary); border-radius: 999px; transition: width .15s ease; }

/* ---- Avatar cropper ---- */
.avatar-cropper-modal { width: min(380px, 92vw); border: none; border-radius: 14px; padding: 1.4rem; background: var(--surface); color: var(--text); }
.avatar-cropper-modal::backdrop { background: rgba(0,0,0,.55); }
.avatar-cropper-modal h2 { margin: 0 0 .2rem; font-size: 1.1rem; }
.avatar-cropper-stage { position: relative; width: 320px; height: 320px; margin: .8rem auto; border-radius: 10px; overflow: hidden; background: #000; touch-action: none; cursor: grab; }
.avatar-cropper-stage:active { cursor: grabbing; }
.avatar-cropper-stage canvas { display: block; }
.avatar-cropper-ring {
  position: absolute; inset: 0; pointer-events: none; border-radius: 50%;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.55);
}
#avatarCropperZoom { width: 100%; margin-top: .3rem; }
