/* Thurn Admin Dashboard — Design System */
:root {
  --teal: #0d6e6e;
  --teal-dark: #094d4d;
  --teal-light: #e0f2f1;
  --gold: #c8a951;
  --bg: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --border: #e5e7eb;
  --border-focus: #0d6e6e;
  --text: #111827;
  --text-muted: #6b7280;
  --text-light: #6b7280;
  --red: #dc2626;
  --green: #16a34a;
  --orange: #ea580c;
  --blue: #2563eb;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius: 8px;
}

html.dark {
  --teal: #2dd4bf;
  --teal-dark: #14b8a6;
  --teal-light: rgba(45, 212, 191, 0.1);
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-input: #0f172a;
  --border: #334155;
  --border-focus: #2dd4bf;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-light: #94a3b8;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
}

@media (prefers-color-scheme: dark) {
  html:not(.light) {
    --teal: #2dd4bf;
    --teal-dark: #14b8a6;
    --teal-light: rgba(45, 212, 191, 0.1);
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #0f172a;
    --border: #334155;
    --border-focus: #2dd4bf;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --text-light: #94a3b8;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
  }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
  border-radius: 4px;
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Admin Header */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 100;
}

.admin-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.125rem;
}

.admin-logo img { width: 32px; height: 32px; }

.admin-nav {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.admin-nav a {
  padding: 0.5rem 0.875rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 6px;
  transition: all 0.15s;
}

.admin-nav a:hover,
.admin-nav a.active {
  background: var(--teal-light);
  color: var(--teal);
}

.admin-header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Admin Layout */
.admin-wrap {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
}

.admin-container {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
}

.admin-page-header {
  margin-bottom: 1.5rem;
}

.admin-page-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.admin-page-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow);
}

.card h2, .card h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Forms */
label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

input, select, textarea {
  width: 100%;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: var(--font);
  background: var(--bg-input);
  color: var(--text);
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(13, 110, 110, 0.1);
}

html.dark input:focus, html.dark select:focus, html.dark textarea:focus {
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.15);
}

@media (prefers-color-scheme: dark) {
  html:not(.light) input:focus, html:not(.light) select:focus, html:not(.light) textarea:focus {
    box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.15);
  }
}

textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.5;
}

.form-group { margin-bottom: 0.75rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.form-meta { font-size: 0.75rem; color: var(--text-light); margin-top: 0.25rem; display: block; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  min-height: 44px;
}

.btn--primary { background: var(--teal); color: white; }
.btn--primary:hover { opacity: 0.9; }
.btn--secondary { background: var(--bg); border: 1px solid var(--border); color: var(--text); }
.btn--secondary:hover { border-color: var(--teal); color: var(--teal); }
.btn--danger { background: var(--red); color: white; }
.btn--danger:hover { opacity: 0.9; }
.btn--sm { padding: 0.4rem 0.75rem; font-size: 0.85rem; min-height: 36px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Tables */
.table-wrap {
  overflow-x: auto;
  margin: 0 -1.25rem;
  padding: 0 1.25rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead th {
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.75rem 0.5rem;
  border-bottom: 2px solid var(--border);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

tbody td {
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

tbody tr:hover {
  background: var(--teal-light);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge--success { background: #d1fae5; color: #065f46; }
.badge--warning { background: #fef3c7; color: #92400e; }
.badge--error { background: #fee2e2; color: #991b1b; }
.badge--info { background: #dbeafe; color: #1e40af; }
.badge--neutral { background: var(--border); color: var(--text-muted); }

html.dark .badge--success { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; }
html.dark .badge--warning { background: rgba(251, 191, 36, 0.15); color: #fcd34d; }
html.dark .badge--error { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
html.dark .badge--info { background: rgba(59, 130, 246, 0.15); color: #93c5fd; }

@media (prefers-color-scheme: dark) {
  html:not(.light) .badge--success { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; }
  html:not(.light) .badge--warning { background: rgba(251, 191, 36, 0.15); color: #fcd34d; }
  html:not(.light) .badge--error { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
  html:not(.light) .badge--info { background: rgba(59, 130, 246, 0.15); color: #93c5fd; }
}

/* Alerts */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
}

.alert--success { background: #d1fae5; color: #065f46; }
.alert--error { background: #fee2e2; color: #991b1b; }
.alert--warning { background: #fef3c7; color: #92400e; }
.alert--info { background: #dbeafe; color: #1e40af; }

html.dark .alert--success { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; }
html.dark .alert--error { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
html.dark .alert--warning { background: rgba(251, 191, 36, 0.15); color: #fcd34d; }
html.dark .alert--info { background: rgba(59, 130, 246, 0.15); color: #93c5fd; }

@media (prefers-color-scheme: dark) {
  html:not(.light) .alert--success { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; }
  html:not(.light) .alert--error { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
  html:not(.light) .alert--warning { background: rgba(251, 191, 36, 0.15); color: #fcd34d; }
  html:not(.light) .alert--info { background: rgba(59, 130, 246, 0.15); color: #93c5fd; }
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.stat-change {
  font-size: 0.8rem;
  font-weight: 500;
}

.stat-change--up { color: var(--green); }
.stat-change--down { color: var(--red); }

/* Theme toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 0.5rem;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: var(--text-muted);
  transition: all 0.15s;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover { border-color: var(--teal); color: var(--teal); }

.theme-icon-dark { display: none; }
html.dark .theme-icon-light { display: none; }
html.dark .theme-icon-dark { display: inline; }

@media (prefers-color-scheme: dark) {
  html:not(.light) .theme-icon-light { display: none; }
  html:not(.light) .theme-icon-dark { display: inline; }
}

/* Login page */
.login-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
}

.login-box {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  text-align: center;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  margin-bottom: 1.5rem;
}

/* Responsive */
@media (max-width: 768px) {
  .admin-nav { display: none; }
  .form-row { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .admin-container { padding: 1rem; }
  input, select, textarea { padding: 0.75rem; font-size: 1rem; }
  .btn { padding: 0.75rem 1.25rem; }
}
