/* /static/css/app.css */
/* DelphiCall Customer UI – global theme */

/*
  Purpose
  -------
  Global base theme and shared design tokens for the Customer UI.

  Responsibilities
  ----------------
  - Define light and dark theme tokens
  - Provide shared typography, spacing and surface styles
  - Supply reusable button, form, table and card base styles

  Theme rules
  -----------
  - Use tokens instead of hardcoded UI colors
  - All new component CSS should build on these variables
  - html[data-theme="light"] and html[data-theme="dark"] are both supported
*/

/* =========================================================
   Theme Tokens – Light
========================================================= */

:root,
html[data-theme="light"] {
  /* Base */
  --bg: #f6f7fc;
  --bg-elevated: #eef1fb;
  --bg-accent: #e8ebfb;

  /* Surfaces */
  --surface: rgba(255, 255, 255, 0.92);
  --surface-solid: #ffffff;
  --surface-soft: #f7f8fe;
  --surface-soft-2: #eef1fb;
  --surface-primary-soft: rgba(109, 72, 255, 0.08);

  /* Text */
  --text: #2a2d3a;
  --text-strong: #171923;
  --text-muted: #6f7487;
  --text-subtle: #a0a5b8;
  --text-on-primary: #ffffff;

  /* Borders */
  --border: #e4e7f2;
  --border-soft: rgba(23, 25, 35, 0.06);
  --border-strong: rgba(23, 25, 35, 0.12);
  --border-primary: rgba(109, 72, 255, 0.26);
  --border-danger: rgba(220, 38, 38, 0.24);

  /* Brand */
  --primary: #6d48ff;
  --primary-600: #5e3ef0;
  --primary-700: #4e32db;
  --primary-soft: rgba(109, 72, 255, 0.12);
  --primary-soft-strong: rgba(109, 72, 255, 0.18);

  --secondary: #4f7cff;
  --secondary-600: #426de9;

  --accent: #8b5cf6;
  --accent-soft: rgba(139, 92, 246, 0.12);

  /* Status */
  --success: #16a34a;
  --success-soft: rgba(22, 163, 74, 0.12);

  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.14);

  --danger: #dc2626;
  --danger-700: #7f1d1d;
  --danger-soft: rgba(220, 38, 38, 0.12);

  /* Effects */
  --ring: rgba(109, 72, 255, 0.18);
  --shadow: 0 18px 42px rgba(30, 32, 48, 0.10);
  --shadow-soft: 0 10px 24px rgba(30, 32, 48, 0.08);
  --shadow-card: 0 10px 30px rgba(30, 32, 48, 0.06);

  /* Radius */
  --radius: 18px;
  --radius-sm: 14px;
  --radius-xs: 10px;

  /* Spacing */
  --space-1: 8px;
  --space-2: 12px;
  --space-3: 16px;
  --space-4: 20px;
  --space-5: 24px;
  --space-6: 32px;

  /* Typography */
  --font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-family-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  /* Icons */
  --icon-stroke: 2.1;
  --icon-color: var(--text-muted);
  --icon-color-strong: var(--primary);

  /* Font weights */
  --fw-normal: 400;
  --fw-medium: 500;
  --fw-strong: 600;

  color-scheme: light;
}

html[data-theme="dark"] {
  /* Base */
  --bg: #0f1020;
  --bg-elevated: #151731;
  --bg-accent: #1b1d3d;

  /* Surfaces */
  --surface: rgba(24, 26, 48, 0.90);
  --surface-solid: #17192f;
  --surface-soft: #1d2040;
  --surface-soft-2: #252852;
  --surface-primary-soft: rgba(139, 92, 246, 0.16);

  /* Text */
  --text: #ececff;
  --text-strong: #ffffff;
  --text-muted: #b4b7d6;
  --text-subtle: #7f84aa;
  --text-on-primary: #ffffff;

  /* Borders */
  --border: rgba(255, 255, 255, 0.08);
  --border-soft: rgba(255, 255, 255, 0.05);
  --border-strong: rgba(255, 255, 255, 0.14);
  --border-primary: rgba(139, 92, 246, 0.30);
  --border-danger: rgba(239, 68, 68, 0.30);

  /* Brand */
  --primary: #8b5cf6;
  --primary-600: #7c4df0;
  --primary-700: #6d3fe0;
  --primary-soft: rgba(139, 92, 246, 0.16);
  --primary-soft-strong: rgba(139, 92, 246, 0.24);

  --secondary: #5b8cff;
  --secondary-600: #4a7cf0;

  --accent: #b388ff;
  --accent-soft: rgba(179, 136, 255, 0.18);

  /* Status */
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.16);

  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.18);

  --danger: #ef4444;
  --danger-700: #fca5a5;
  --danger-soft: rgba(239, 68, 68, 0.18);

  /* Effects */
  --ring: rgba(139, 92, 246, 0.28);
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.40);
  --shadow-soft: 0 10px 24px rgba(0, 0, 0, 0.30);
  --shadow-card:
    0 10px 28px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);

  /* Icons */
  --icon-stroke: 2.2;
  --icon-color: var(--text-muted);
  --icon-color-strong: var(--primary);

  /* Font weights */
  --fw-normal: 400;
  --fw-medium: 500;
  --fw-strong: 600;

  color-scheme: dark;
}

/* =========================================================
   Base
========================================================= */

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-family);
  font-size: 15px;
  line-height: 1.5;
  font-weight: var(--fw-normal);
  color: var(--text);

  background:
    radial-gradient(900px 600px at 10% 0%, rgba(109, 72, 255, 0.08), transparent 60%),
    radial-gradient(900px 600px at 90% 10%, rgba(79, 124, 255, 0.08), transparent 60%),
    linear-gradient(135deg, #f7f8fe 0%, #eef1fb 45%, #e9ecfb 100%);

  background-attachment: fixed;
}

html[data-theme="dark"] body {
  background:
    radial-gradient(900px 600px at 10% 0%, rgba(139, 92, 246, 0.20), transparent 60%),
    radial-gradient(900px 600px at 90% 10%, rgba(91, 140, 255, 0.16), transparent 60%),
    linear-gradient(135deg, #0f1020 0%, #13152a 40%, #1a1d3d 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 0%, rgba(255,255,255,0.4), transparent 60%);
  z-index: 0;
}

body,
button,
input,
select,
textarea {
  font-family: var(--font-family);
  font-weight: var(--fw-normal);
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  color: var(--accent);
}

img {
  display: block;
  max-width: 100%;
}

svg.lucide {
  stroke-width: var(--icon-stroke);
}

h1,
h2,
h3,
h4,
h5,
h6,
p {
  margin: 0;
}

strong,
b {
  font-weight: var(--fw-strong);
}

h1,
.h1 {
  font-size: clamp(1.9rem, 1.4rem + 1.2vw, 2.5rem);
  line-height: 1.08;
  font-weight: var(--fw-strong);
  letter-spacing: -0.03em;
  color: var(--text-strong);
}

h2,
.h2 {
  font-size: clamp(1.25rem, 1.05rem + 0.4vw, 1.6rem);
  line-height: 1.15;
  font-weight: var(--fw-strong);
  letter-spacing: -0.02em;
  color: var(--text-strong);
}

h3,
.h3 {
  font-size: 1.05rem;
  line-height: 1.25;
  font-weight: var(--fw-strong);
  color: var(--text-strong);
}

small,
.small {
  font-size: 12px;
}

.muted {
  color: var(--text-muted);
}

.mono {
  font-family: var(--font-family-mono);
}

/* =========================================================
   Layout Helpers
========================================================= */

.container {
  width: min(1320px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.page-head,
.page-shell,
.page-section {
  margin-bottom: 24px;
}

.page-head {
  padding: 6px 2px 0;
}

.page-head h1,
.page-shell h1,
.card h1,
.card h2,
.card h3 {
  overflow-wrap: anywhere;
}

/* =========================================================
   Surfaces
========================================================= */

.card,
.topbar,
.panel,
.header-card {
  background: var(--surface);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.card {
  padding: 22px;
}

.card-accent {
  position: relative;
  overflow: hidden;
}

.card-accent::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--primary) 0%, var(--secondary) 100%);
}

/* =========================================================
   Forms
========================================================= */

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-solid);
  color: var(--text);
  padding: 12px 14px;
  font-size: 15px;
  font-weight: var(--fw-normal);
  outline: none;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease,
    color 0.18s ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-subtle);
}

input:focus,
select:focus,
textarea:focus {
  border-color: color-mix(in srgb, var(--secondary) 45%, var(--border));
  box-shadow: 0 0 0 4px var(--ring);
}

input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* =========================================================
   Buttons
========================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--secondary) 0%, color-mix(in srgb, var(--secondary) 76%, var(--primary)) 100%);
  color: var(--text-on-primary);
  font-size: 14px;
  font-weight: var(--fw-strong);
  line-height: 1;
  cursor: pointer;
  box-shadow:
    0 12px 26px color-mix(in srgb, var(--secondary) 18%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
  transition:
    transform 0.12s ease,
    box-shadow 0.16s ease,
    filter 0.16s ease,
    border-color 0.16s ease,
    background 0.16s ease,
    color 0.16s ease;
}

.btn:hover {
  color: var(--text-on-primary);
  transform: translateY(-1px);
  filter: brightness(1.03);
  box-shadow:
    0 16px 30px color-mix(in srgb, var(--secondary) 22%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  filter: none;
  box-shadow: none;
}

.btn:focus,
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus {
  outline: none;
}

.btn:focus-visible,
a:focus-visible,
button:focus-visible {
  box-shadow: 0 0 0 4px var(--ring);
}

.btn-secondary {
  background: var(--surface-solid);
  color: var(--text-strong);
  border-color: var(--border);
  box-shadow:
    0 8px 18px color-mix(in srgb, var(--text-strong) 8%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.btn-secondary:hover {
  color: var(--accent);
  background: var(--surface-soft);
  border-color: color-mix(in srgb, var(--accent) 28%, var(--border));
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
  box-shadow: none;
}

.btn-ghost:hover {
  color: var(--text-strong);
  background: color-mix(in srgb, var(--surface-soft) 70%, transparent);
  box-shadow: none;
}

.btn-sm {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 12px;
  font-size: 13px;
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger) 0%, color-mix(in srgb, var(--danger) 72%, #7f1d1d) 100%);
  color: #ffffff;
}

/* =========================================================
   Pills / Notices / Alerts
========================================================= */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border-radius: 999px;
  background: var(--primary-soft);
  border: 1px solid var(--border-primary);
  color: var(--primary-600);
  font-size: 12px;
  font-weight: var(--fw-medium);
}

.notice {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  box-shadow: 0 10px 20px color-mix(in srgb, var(--text-strong) 6%, transparent);
}

.notice.error,
.alert-error {
  background: var(--danger-soft);
  border-color: var(--border-danger);
  color: var(--danger-700);
}

/* =========================================================
   Search
========================================================= */

.search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 560px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
}

.search input {
  border: 0;
  box-shadow: none;
  padding: 0;
  background: transparent;
}

/* =========================================================
   Tables
========================================================= */

.table-wrap {
  overflow-x: auto;
}

table,
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface-solid);
}

thead th,
.table thead th {
  text-align: left;
  padding: 14px 16px;
  font-size: 12px;
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: linear-gradient(180deg, var(--surface-solid) 0%, var(--surface-soft) 100%);
  border-bottom: 1px solid var(--border);
}

tbody td,
.table tbody td {
  padding: 15px 16px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  color: var(--text);
  vertical-align: middle;
}

tbody tr:last-child td,
.table tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td,
.table tbody tr:hover td {
  background: color-mix(in srgb, var(--surface-primary-soft) 75%, transparent);
}

/* =========================================================
   Theme Toggle
========================================================= */

.btn-theme-toggle {
  min-width: 112px;
}

.btn-theme-toggle svg.lucide {
  width: 16px;
  height: 16px;
}

/* =========================================================
   Misc
========================================================= */

.logout-form {
  margin: 0;
}

.logout-form button {
  all: unset;
  cursor: pointer;
}

/* =========================================================
   Responsive
========================================================= */

@media (max-width: 768px) {
  .container {
    width: min(100% - 24px, 1320px);
    padding-top: 18px;
  }

  .card {
    padding: 18px;
  }

  .page-head,
  .page-shell,
  .page-section {
    margin-bottom: 18px;
  }
}

