/* Admin-specific styles */

:root {
  --admin-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --admin-font-size-base: clamp(1rem, 0.95rem + 0.5vw, 1.075rem);
  --admin-line-height: 1.55;
  --admin-bg: #eef2f8;
  --admin-bg-soft: #f8fafc;
  --admin-surface: #ffffff;
  --admin-sidebar-bg: #ffffff;
  --admin-sidebar-text: #444444;
  --admin-sidebar-muted: #64748b;
  --admin-border: #e2e8f0;
  --admin-border-strong: #cbd5f5;
  --admin-primary: #2563eb;
  --admin-primary-soft: #e0f2fe;
  --admin-primary-strong: #1d4ed8;
  --admin-accent: #38bdf8;
  --admin-radius-md: 0.75rem;
  --admin-radius-lg: 1rem;
  --admin-shadow: 0 25px 55px -20px rgba(15, 23, 42, 0.55);
  --admin-shadow-soft: 0 18px 40px -22px rgba(15, 23, 42, 0.35);
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  font-family: var(--admin-font-family);
  font-size: var(--admin-font-size-base);
  line-height: var(--admin-line-height);
  color: var(--admin-sidebar-text);
  background: linear-gradient(180deg, var(--admin-bg-soft) 0%, var(--admin-bg) 100%);
  -webkit-font-smoothing: antialiased;
}

.admin-body {
  min-height: 100vh;
  background: inherit;
}

.admin-shell {
  display: flex;
  min-height: 100vh;
  background: transparent;
}

.admin-nav-toggle {
  display: none;
}

.admin-sidebar {
  width: clamp(240px, 22vw, 280px);
  background: var(--admin-sidebar-bg);
  color: var(--admin-sidebar-text);
  padding: 2rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  border-right: 1px solid var(--admin-border);
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
}

.admin-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0 1rem;
}

.admin-brand {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--admin-sidebar-text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-sidebar-close {
  display: none;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 0.85rem;
  border: 1px solid var(--admin-border);
  background: rgba(148, 163, 184, 0.12);
  color: var(--admin-sidebar-muted);
  font-size: 1.5rem;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease;
}

.admin-sidebar-close:hover,
.admin-sidebar-close:focus {
  background: rgba(148, 163, 184, 0.25);
}

.admin-sidebar-nav {
  display: flex;
  flex-direction: column;
}

.admin-sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 1rem;
  color: var(--admin-sidebar-text);
  font-weight: 500;
  font-size: 0.975rem;
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  border-radius: 0.7rem;
}

.admin-sidebar-link svg {
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.admin-sidebar-link:hover,
.admin-sidebar-link:focus {
  background: #f7f7f7;
  color: var(--admin-primary-strong);
  text-decoration: none;
}

.admin-sidebar-link:hover svg,
.admin-sidebar-link:focus svg {
  transform: translateX(2px);
}

.admin-sidebar-link.is-active {
  background: #f7f7f7;
  color: var(--admin-primary);
  box-shadow: 0 22px 40px -24px rgba(37, 99, 235, 0.15);
}

.admin-sidebar-link.is-active:hover,
.admin-sidebar-link.is-active:focus {
  background: var(--admin-bg-soft);
  color: var(--admin-primary-strong);
}

.admin-sidebar-footer {
  margin-top: auto;
  padding: 1.75rem 1rem 0;
  border-top: 1px solid var(--admin-border);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.admin-user-email {
  font-size: 0.85rem;
  color: var(--admin-sidebar-muted);
  word-break: break-word;
  text-align: center;
}

.admin-sign-out {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--admin-primary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 1.1rem;
  border-radius: 9999px;
  background: #ffffff;
  border: 1px solid var(--admin-border);
  box-shadow: 0 16px 32px -24px rgba(37, 99, 235, 0.75);
  transition: all 0.2s ease;
}

.admin-sign-out:hover,
.admin-sign-out:focus {
  background: linear-gradient(135deg, var(--admin-primary) 0%, var(--admin-accent) 100%);
  color: #ffffff;
  border-color: transparent;
}

.admin-sidebar-overlay {
  display: none;
}

.admin-main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: clamp(1rem, 0.75rem + 1vw, 1.6rem) clamp(1.25rem, 1rem + 2vw, 2.5rem);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
  position: sticky;
  top: 0;
  z-index: 10;
}

.admin-topbar-heading {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.admin-menu-button {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.9rem;
  border: 1px solid var(--admin-border);
  padding: 0.5rem;
  cursor: pointer;
  background-color: #ffffff;
  box-shadow: 0 18px 30px -25px rgba(15, 23, 42, 0.6);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.admin-menu-button:hover,
.admin-menu-button:focus {
  transform: translateY(-1px);
  box-shadow: 0 22px 35px -25px rgba(15, 23, 42, 0.65);
}

.admin-menu-button span {
  height: 2px;
  width: 1.4rem;
  background: linear-gradient(90deg, var(--admin-sidebar-text) 0%, var(--admin-primary) 100%);
  border-radius: 9999px;
}

.admin-topbar-title-group {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.admin-topbar-eyebrow {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: #94a3b8;
}

.admin-topbar-title {
  font-size: clamp(1.35rem, 1.1rem + 0.8vw, 1.85rem);
  font-weight: 600;
  color: var(--admin-sidebar-text);
  margin: 0;
}

.admin-topbar-user {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  border-radius: 9999px;
  border: 1px solid var(--admin-border);
  padding: 0.4rem 0.6rem 0.4rem 0.4rem;
  background: rgba(15, 23, 42, 0.03);
  box-shadow: 0 18px 36px -28px rgba(15, 23, 42, 0.7);
}

.admin-user-avatar {
  display: grid;
  place-items: center;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 9999px;
  background: linear-gradient(135deg, var(--admin-primary) 0%, var(--admin-accent) 100%);
  color: #ffffff;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.admin-user-details {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
  line-height: 1.3;
}

.admin-user-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--admin-sidebar-text);
}

.admin-topbar-user .admin-user-email {
  font-size: 0.8rem;
  color: #64748b;
}

.admin-topbar-user .admin-sign-out {
  margin-left: 0.5rem;
  white-space: nowrap;
  box-shadow: none;
}

.admin-view-website-btn {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--admin-primary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 1.1rem;
  border-radius: 9999px;
  background: #ffffff;
  border: 1px solid var(--admin-border);
  box-shadow: 0 16px 32px -24px rgba(37, 99, 235, 0.75);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.admin-view-website-btn:hover,
.admin-view-website-btn:focus {
  background: linear-gradient(135deg, var(--admin-primary) 0%, var(--admin-accent) 100%);
  color: #ffffff;
  border-color: transparent;
  text-decoration: none;
}

.admin-content {
  flex: 1;
  width: 100%;
  margin: 0 auto;
  padding: clamp(1.75rem, 1.25rem + 2vw, 3.25rem) clamp(1.5rem, 1.1rem + 2vw, 3rem) clamp(3rem, 2rem + 3vw, 4rem);
}

.flash {
  margin-bottom: 1.75rem;
  display: grid;
  gap: 0.9rem;
}

.flash-notice,
.flash-alert {
  padding: 1rem 1.25rem;
  border-radius: var(--admin-radius-lg);
  font-weight: 500;
  border: 1px solid transparent;
  box-shadow: 0 18px 35px -24px rgba(15, 23, 42, 0.5);
}

.flash-notice {
  background-color: #dcfce7;
  border-color: #86efac;
  color: #166534;
}

.flash-alert {
  background-color: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.25rem;
  margin-bottom: 2.25rem;
}

.page-title {
  font-size: clamp(1.75rem, 1.4rem + 0.8vw, 2.35rem);
  font-weight: 700;
  color: var(--admin-sidebar-text);
  margin: 0;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  align-items: center;
}

.page-actions form {
  margin: 0;
}

.admin-card {
  background-color: var(--admin-surface);
  border-radius: var(--admin-radius-lg);
  padding: clamp(1.5rem, 1.25rem + 1vw, 2.25rem);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
  border: 1px solid rgba(226, 232, 240, 0.9);
  margin-bottom: 2rem;
}

.admin-card-title {
  font-size: clamp(1.2rem, 1.05rem + 0.4vw, 1.5rem);
  font-weight: 600;
  color: var(--admin-sidebar-text);
  margin: 0 0 1.35rem;
}

.admin-card-subtitle {
  font-size: clamp(1rem, 0.95rem + 0.2vw, 1.1rem);
  font-weight: 600;
  color: #334155;
  margin: 1.5rem 0 0.9rem;
}

/* Header row with title + action button */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.admin-header .admin-subtitle {
  margin: 0;
}

/* Standalone section subtitle (not in cards) */
.admin-subtitle {
  font-size: clamp(1.2rem, 1.05rem + 0.4vw, 1.5rem);
  font-weight: 600;
  color: var(--admin-sidebar-text);
  margin: 0 0 1.35rem;
}

.empty-state {
  font-size: 0.975rem;
  color: #64748b;
  padding: 0.5rem 0;
}

.styled-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.65rem;
}

.styled-list li {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--admin-border);
}

.styled-list li:last-child {
  border-bottom: none;
}

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--admin-radius-lg);
  border: 1px solid var(--admin-border);
  background: var(--admin-surface);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
}

table.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
  font-size: clamp(0.92rem, 0.85rem + 0.2vw, 0.98rem);
}

table.admin-table thead {
  background-color: var(--admin-bg-soft);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  color: #475569;
}

table.admin-table th,
table.admin-table td {
  text-align: left;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--admin-border);
  color: #1e293b;
  vertical-align: middle;
}

table.admin-table tbody tr:hover {
  background-color: rgba(226, 232, 240, 0.4);
}

table.admin-table tbody tr:last-child td {
  border-bottom: none;
}

dl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.1rem 1.5rem;
}

dl > div {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

dt {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
}

dd {
  margin: 0;
  font-size: 1rem;
  color: var(--admin-sidebar-text);
}

.form-group {
  margin-bottom: 1.4rem;
}

.form-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.55rem;
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: clamp(0.95rem, 0.9rem + 0.2vw, 1.05rem);
  border-radius: var(--admin-radius-md);
  border: 1px solid var(--admin-border-strong);
  background-color: #ffffff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none;
  border-color: var(--admin-primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.16);
}

.form-helper-text {
  font-size: 0.82rem;
  color: #64748b;
  margin-top: 0.35rem;
}

.form-actions {
  margin-top: 1.75rem;
  display: flex;
  gap: 0.9rem;
  flex-wrap: wrap;
}

.form-errors {
  background-color: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--admin-radius-lg);
  padding: 1.35rem;
  margin-bottom: 1.6rem;
  box-shadow: 0 22px 45px -30px rgba(185, 28, 28, 0.55);
}

.form-errors h2 {
  font-size: 0.98rem;
  font-weight: 600;
  color: #b91c1c;
  margin: 0 0 0.85rem 0;
}

.form-errors ul {
  margin: 0;
  padding-left: 1.3rem;
  color: #b91c1c;
  font-size: 0.9rem;
}

.message {
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius-md);
  padding: 0.7rem 1rem 0;
  margin-bottom: 1.1rem;
  background-color: var(--admin-surface);
}

.message-user {
  background-color: var(--admin-bg-soft);
}

.message-assistant {
  background-color: oklch(97% 0.014 254.604);
  .message-header {
    color: var(--admin-primary);
  }
}

.message-system {
  border-left: 4px solid #f59e0b;
  background-color: #fffbeb;
}

.message-header {
  font-weight: 600;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: #475569;
}

.message-content {
  color: var(--admin-sidebar-text);
  line-height: 1.6;
}

.change-request-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.85rem;
}

.change-request-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.95rem 1.1rem;
  border-radius: var(--admin-radius-md);
  border: 1px solid var(--admin-border);
  background-color: var(--admin-bg-soft);
}

.table-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
  width: 100%;
}

.table-actions form {
  margin: 0;
}

.info-box {
  padding: 1.35rem;
  border-radius: var(--admin-radius-lg);
  border: 1px solid var(--admin-border);
  background-color: var(--admin-bg-soft);
  margin-bottom: 1.35rem;
  color: #1e293b;
  line-height: 1.65;
}

.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
}

@media (max-width: 1280px) {
  .admin-content {
    width: min(100%, calc(100% - clamp(2rem, 6vw, 4rem)));
  }
}

@media (max-width: 1024px) {
  .admin-shell {
    position: relative;
  }

  .admin-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    transform: translateX(-105%);
    max-width: min(80vw, 320px);
    z-index: 20;
    box-shadow: var(--admin-shadow);
  }

  .admin-sidebar-close {
    display: inline-flex;
  }

  #admin-nav-toggle:checked ~ .admin-shell .admin-sidebar {
    transform: translateX(0);
  }

  .admin-sidebar-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.45);
    z-index: 10;
    display: none;
  }

  #admin-nav-toggle:checked ~ .admin-shell .admin-sidebar-overlay {
    display: block;
  }

  .admin-content {
    padding: 2rem 1.5rem 3rem;
  }
}

@media (max-width: 768px) {
  .admin-topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-view-website-btn {
    width: 100%;
    justify-content: center;
  }

  .admin-topbar-user {
    width: 100%;
    justify-content: space-between;
  }

  .admin-topbar-user .admin-user-details {
    flex: 1;
  }

  .admin-topbar-user .admin-sign-out {
    margin-left: 1rem;
  }

  .admin-content {
    padding: 1.75rem 1.25rem 2.5rem;
  }
}

@media (max-width: 640px) {
  .page-actions {
    width: 100%;
  }

  .page-actions > * {
    flex: 1 1 100%;
  }

  .page-actions .btn,
  .page-actions form .btn {
    width: 100%;
    justify-content: center;
  }

  .admin-topbar-user {
    padding-right: 0.45rem;
  }

  .admin-topbar-user .admin-user-email {
    display: none;
  }

  .admin-sidebar .admin-sign-out {
    width: 100%;
    justify-content: center;
  }
}

/* Analytics page specific styles */
.analytics-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.analytics-two-column {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

.analytics-three-column {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
}

.stat-card-label {
  margin: 0 0 0.5rem 0;
  color: #666;
  font-size: 0.875rem;
}

.stat-card-value {
  font-size: 2rem;
  font-weight: bold;
}

.stat-card-value.success {
  color: #22c55e;
}

.stat-card-value.warning {
  color: #f59e0b;
}

.stat-card-value.error {
  color: #ef4444;
}

.date-filter-form {
  display: flex;
  gap: 1rem;
  align-items: end;
}

@media (max-width: 768px) {
  .analytics-two-column {
    grid-template-columns: 1fr;
  }

  .analytics-three-column {
    grid-template-columns: 1fr;
  }

  .date-filter-form {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (min-width: 1025px) {
  .admin-menu-button {
    display: none;
  }

  .admin-sidebar {
    transform: none !important;
  }

  .admin-sidebar-overlay {
    display: none !important;
  }
}
