/*
 * DealerFAI — Modern Professional Stylesheet
 *
 * Colours come from per-org CSS custom properties injected via a PHP nonce'd <style> block.
 */

/* ─── Reset & Base ──────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --bg-subtle: #f8fafc;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.3);
  --glass-blur: 12px;
}

body {
  margin: 0;
  font-family: var(--font-main);
  background-color: var(--page-bg, var(--bg-subtle));
  background-attachment: fixed;
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.bg-ai::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.4);
  /* Dark overlay to make white text pop */
  z-index: -1;
}

/* ─── Layout Chrome ─────────────────────────────────────────────────────────── */
header {
  background-color: var(--header-bg, #ffffff);
  color: var(--header-text, #1e293b);
  padding: 2.5rem 2rem;
  text-align: center;
  position: relative;
  border-bottom: 1px solid var(--border-color);
}

header img {
  max-width: 320px;
  max-height: 80px;
  height: auto;
  display: block;
  margin: 0 auto 1.5rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.05));
}

header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

nav {
  background-color: var(--nav-bg, #ffffff);
  padding: 0.75rem;
  text-align: center;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
  background-color: rgba(255, 255, 255, 0.8);
}

nav a {
  color: var(--nav-text, #475569);
  margin: 0 1rem;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  transition: var(--transition);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
}

nav a:hover {
  color: var(--brand-color);
  background-color: var(--accent-soft);
}

main {
  padding: 3rem 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

footer {
  background-color: var(--text-main);
  color: #ffffff;
  text-align: center;
  padding: 3rem 2rem;
  font-size: 0.875rem;
  margin-top: 5rem;
  border-top: 1px solid var(--border-color);
}

footer p {
  opacity: 0.6;
}

/* ─── Header Logout / Action Area ───────────────────────────────────────────── */
.header-actions,
.logout {
  position: absolute;
  right: 2rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 1rem;
  align-items: center;
}

.header-actions a,
.logout a {
  color: var(--header-text);
  font-size: 0.875rem;
  text-decoration: none;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  transition: var(--transition);
}

.header-actions a:hover,
.logout a:hover {
  background-color: var(--bg-subtle);
  border-color: var(--text-muted);
}

/* ─── Headings ───────────────────────────────────────────────────────────────── */
h2 {
  color: var(--text-main);
  text-align: center;
  margin-bottom: 2rem;
  font-size: 1.875rem;
  font-weight: 800;
  letter-spacing: -0.025em;
}

h3 {
  color: var(--text-main);
  margin-top: 2.5rem;
  font-size: 1.25rem;
  font-weight: 700;
}

/* ─── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg, #ffffff);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin: 1.5rem auto;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.card h3 {
  margin-top: 0;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
}

/* ─── Forms ──────────────────────────────────────────────────────────────────── */
label {
  display: block;
  margin-top: 1.25rem;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-main);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="tel"],
select,
textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  margin-top: 0.5rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: #ffffff;
  font-size: 1rem;
  font-family: inherit;
  transition: var(--transition);
  color: var(--text-main);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand-color);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.btn,
button[type="submit"] {
  background-color: var(--brand-color);
  color: #ffffff;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius-md);
  margin-top: 1.5rem;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-decoration: none;
  transition: var(--transition);
  box-shadow: 0 4px 6px -1px rgba(var(--brand-hsl), 0.2);
}

.btn:hover,
button[type="submit"]:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 10px 15px -3px rgba(var(--brand-hsl), 0.3);
}

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

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  margin-top: 0;
}

.btn-danger {
  background-color: #dc2626;
  box-shadow: 0 4px 6px -1px rgba(220, 38, 38, 0.2);
}

.btn-success {
  background-color: #16a34a;
  box-shadow: 0 4px 6px -1px rgba(22, 163, 74, 0.2);
}

.btn-secondary {
  background-color: var(--bg-subtle);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background-color: var(--border-color);
}

/* ─── Tables ─────────────────────────────────────────────────────────────────── */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  margin-top: 2rem;
  border: 1px solid var(--border-color);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

th,
td {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
}

th {
  background-color: var(--bg-subtle);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background-color: var(--accent-soft);
}

/* ─── Alerts / Banners ───────────────────────────────────────────────────────── */
.alert {
  max-width: 100%;
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid transparent;
}

.alert-success {
  background: #f0fdf4;
  color: #166534;
  border-color: #bbf7d0;
}

.alert-error,
.alert-danger {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

.alert-warning {
  background: #fffbeb;
  color: #92400e;
  border-color: #fef3c7;
}

.alert-info {
  background: #eff6ff;
  color: #1e40af;
  border-color: #bfdbfe;
}

/* ─── Dialogs / Modals ───────────────────────────────────────────────────────── */
dialog {
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  width: min(500px, 94vw);
  box-shadow: var(--shadow-lg);
  background: #ffffff;
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
}

.dialog-header {
  background: var(--brand-color);
  color: white;
  padding: 1.25rem 1.5rem;
  font-weight: 700;
  font-size: 1.125rem;
}

.dialog-body {
  padding: 1.5rem;
}

.dialog-actions {
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background: var(--bg-subtle);
  border-top: 1px solid var(--border-color);
}

/* ─── Filter bars ────────────────────────────────────────────────────────────── */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  background: #ffffff;
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  margin-bottom: 2rem;
}

.filters input,
.filters select {
  margin-top: 0;
  min-width: 200px;
}

/* ─── Details / Summary ──────────────────────────────────────────────────────── */
details {
  margin-top: 1.5rem;
  background: white;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1rem;
  transition: var(--transition);
}

details[open] {
  padding-bottom: 1.5rem;
}

summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--brand-color);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

summary::before {
  content: '→';
  transition: var(--transition);
}

details[open] summary::before {
  transform: rotate(90deg);
}

/* ─── Utility Classes ────────────────────────────────────────────────────────── */
.text-center {
  text-align: center;
}

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

.mt-0 {
  margin-top: 0;
}

.mt-4 {
  margin-top: 1rem;
}

.mb-4 {
  margin-bottom: 1rem;
}

.flex {
  display: flex;
}

.gap-2 {
  gap: 0.5rem;
}

.gap-4 {
  gap: 1rem;
}

.items-center {
  align-items: center;
}

.justify-center {
  justify-content: center;
}

/* ─── Section header bar ─────────────────────────────────────────────────────── */
.card-header-bar {
  background: var(--text-main);
  color: #fff;
  padding: 1rem 2rem;
  margin: -2rem -2rem 2rem -2rem;
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
}

/* ─── Badge ─────────────────────────────────────────────────────────────────── */
.badge {
  background: #dc2626;
  color: white;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

/* ─── Modern UI Utilities ────────────────────────────────────────────────────── */
.glass {
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
}

.bg-ai {
  background-image: url('/assets/img/ai_bg.png');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  min-height: 100vh;
}

.full-page-center {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  min-height: 100vh;
  padding: 2rem;
}

.text-gradient {
  background: linear-gradient(135deg, var(--brand-color) 0%, #1e293b 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-box {
  padding: 5rem 2rem;
  border-radius: var(--radius-lg);
  margin-bottom: 3rem;
  position: relative;
  overflow: hidden;
}

.hero-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 50% 0%, var(--accent-glow) 0%, transparent 70%);
  pointer-events: none;
}

/* ─── Header Overrides for Landing/Login ───────────────────────────────────── */
.clean-header {
  background: transparent;
  border: none;
  padding: 2rem;
}

.clean-header img {
  margin-bottom: 0;
  max-width: 240px;
}

.clean-header h1 {
  display: none;
  /* Hide redundant text if logo has it */
}.dashboard-wrapper {
  display: flex;
  min-height: 100vh;
  background-color: #f8fafc;
}

.sidebar {
  width: 280px;
  background: #0f172a;
  color: white;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 1000;
}

.sidebar-header {
  padding: 2rem;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-nav {
  flex: 1;
  padding: 1.5rem 1rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  border-radius: var(--radius-md);
  margin-bottom: 0.5rem;
  transition: all 0.2s;
  font-weight: 500;
}

.sidebar-link:hover, .sidebar-link.active {
  background: rgba(255,255,255,0.1);
  color: white;
}

.sidebar-link i {
  width: 20px;
  text-align: center;
}

.main-container {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.top-bar {
  background: white;
  height: 70px;
  padding: 0 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 900;
}

.page-content {
  padding: 2.5rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.metric-card {
  background: white;
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid #e2e8f0;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
}

.metric-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.metric-card .label {
  font-size: 0.875rem;
  color: #64748b;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.metric-card .value {
  font-size: 1.875rem;
  font-weight: 700;
  color: #0f172a;
  margin-top: 0.5rem;
}

.data-table-card {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid #e2e8f0;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.data-table-header {
  padding: 1.5rem;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.clean-header h1 {
  display: none; /* Hide redundant text if logo has it */
}
