/* ==========================================================================
   THEME CONFIGURATION
   --------------------------------------------------------------------------
   All colors, spacing, and other reusable values live here as CSS custom
   properties. Tweak these to re-theme the entire dashboard without touching
   any other rule below.
   ========================================================================== */
:root {
  /* Backgrounds */
  --color-bg: #0f172a;              /* deep charcoal/slate base */
  --color-bg-alt: #111c34;          /* slightly lighter panel background */
  --color-surface: #16213d;         /* card background */
  --color-surface-hover: #1b2a4d;   /* card background on hover */

  /* Borders */
  --color-border: #263354;
  --color-border-hover: #3b82f6;

  /* Text */
  --color-text-primary: #f1f5f9;
  --color-text-secondary: #94a3b8;
  --color-text-muted: #64748b;

  /* Accent / brand */
  --color-accent: #3b82f6;          /* blue */
  --color-accent-alt: #8b5cf6;      /* violet, used in gradients */
  --color-accent-soft: rgba(59, 130, 246, 0.15);

  /* Glow / shadow effects */
  --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-card-hover: 0 12px 32px rgba(59, 130, 246, 0.25);
  --glow-accent: 0 0 40px rgba(59, 130, 246, 0.35);

  /* Spacing scale */
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2.5rem;
  --space-xl: 4rem;

  /* Radii */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;

  /* Typography */
  --font-family-base: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;

  /* Transitions */
  --transition-fast: 180ms ease;
  --transition-medium: 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* ==========================================================================
   RESET & BASE STYLES
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-family-base);
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  position: relative;
}

/* ==========================================================================
   AMBIENT BACKGROUND GLOW
   ========================================================================== */
.background-glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.35;
}

.glow--one {
  width: 500px;
  height: 500px;
  top: -150px;
  left: -100px;
  background: var(--color-accent);
}

.glow--two {
  width: 500px;
  height: 500px;
  bottom: -150px;
  right: -100px;
  background: var(--color-accent-alt);
}

/* ==========================================================================
   LOGIN VIEW
   --------------------------------------------------------------------------
   Shown by auth.js when no valid `dashboard_auth` cookie is present.
   ========================================================================== */
.login-view {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
}

.login-card {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-lg) var(--space-md);
  background: linear-gradient(160deg, var(--color-surface), var(--color-bg-alt));
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  text-align: center;
}

.login-card__icon-wrap {
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-alt));
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
  margin-bottom: var(--space-xs);
}

.login-card__icon-wrap svg {
  width: 28px;
  height: 28px;
  stroke: #ffffff;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.login-card__title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text-primary);
}

.login-card__subtitle {
  margin: 0 0 var(--space-xs);
  font-size: 0.95rem;
  color: var(--color-text-secondary);
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  text-align: left;
}

.login-field__label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-secondary);
}

.login-field__input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  font-family: var(--font-family-base);
  font-size: 0.95rem;
  color: var(--color-text-primary);
  background-color: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

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

.login-field__input:focus {
  border-color: var(--color-border-hover);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}

.login-error {
  margin: 0;
  padding: 0.6rem 0.8rem;
  font-size: 0.85rem;
  color: #fca5a5;
  background-color: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: var(--radius-sm);
}

.login-submit {
  margin-top: var(--space-xs);
  padding: 0.75rem 1rem;
  font-family: var(--font-family-base);
  font-size: 0.95rem;
  font-weight: 600;
  color: #ffffff;
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-alt));
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.login-submit:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover), var(--glow-accent);
}

.login-submit:active {
  transform: translateY(0);
}

.login-submit:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

/* ==========================================================================
   LAYOUT
   ========================================================================== */
.dashboard {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--space-xl) var(--space-md);
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   HEADER
   ========================================================================== */
.dashboard-header {
  text-align: center;
  margin-bottom: var(--space-xl);
}

/* ==========================================================================
   LOGOUT BUTTON
   ========================================================================== */
.logout-btn {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  font-family: var(--font-family-base);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast),
    background-color var(--transition-fast);
}

.logout-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.logout-btn:hover,
.logout-btn:focus-visible {
  color: var(--color-text-primary);
  border-color: var(--color-border-hover);
  background-color: var(--color-surface-hover);
}

.logout-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

.eyebrow {
  margin: 0 0 var(--space-xs);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-accent);
}

.title {
  margin: 0 0 var(--space-xs);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  background: linear-gradient(135deg, var(--color-text-primary), var(--color-text-secondary));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  margin: 0;
  font-size: 1.05rem;
  color: var(--color-text-secondary);
}

/* ==========================================================================
   SERVICE GRID & CARDS
   ========================================================================== */
.service-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-md);
  flex: 1;
}

.service-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: linear-gradient(160deg, var(--color-surface), var(--color-bg-alt));
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: transform var(--transition-medium),
    border-color var(--transition-medium), box-shadow var(--transition-medium),
    background var(--transition-medium);
}

/* Subtle gradient sheen that appears on hover */
.service-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at var(--mouse-x, 50%) var(--mouse-y, 0%),
    var(--color-accent-soft),
    transparent 60%
  );
  opacity: 0;
  transition: opacity var(--transition-medium);
  pointer-events: none;
}

.service-card:hover,
.service-card:focus-visible {
  transform: translateY(-6px);
  border-color: var(--color-border-hover);
  background: linear-gradient(160deg, var(--color-surface-hover), var(--color-bg-alt));
  box-shadow: var(--shadow-card-hover), var(--glow-accent);
}

.service-card:hover::before,
.service-card:focus-visible::before {
  opacity: 1;
}

.service-card:active {
  transform: translateY(-2px) scale(0.99);
}

.service-card:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

.service-card__icon-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-alt));
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
  flex-shrink: 0;
  transition: transform var(--transition-medium);
}

.service-card:hover .service-card__icon-wrap {
  transform: scale(1.08) rotate(-4deg);
}

.service-card__icon-wrap svg {
  width: 24px;
  height: 24px;
  stroke: #ffffff;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.service-card__body {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.service-card__title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--color-text-primary);
}

.service-card__description {
  margin: 0;
  font-size: 0.9rem;
  color: var(--color-text-secondary);
}

.service-card__footer {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-accent);
}

.service-card__footer svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--transition-medium);
}

.service-card:hover .service-card__footer svg {
  transform: translateX(4px);
}

/* ==========================================================================
   FOOTER
   ========================================================================== */
.dashboard-footer {
  margin-top: var(--space-xl);
  text-align: center;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* ==========================================================================
   RESPONSIVE ADJUSTMENTS
   ========================================================================== */
@media (max-width: 640px) {
  .dashboard {
    padding: var(--space-lg) var(--space-sm);
  }

  .service-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-header {
    margin-bottom: var(--space-lg);
  }
}

@media (min-width: 641px) and (max-width: 900px) {
  .service-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .logout-btn span {
    display: none;
  }

  .logout-btn {
    padding: 0.5rem;
  }
}

/* ==========================================================================
   REDUCED MOTION SUPPORT
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   VISIBILITY HELPER (Fixes HTML hidden attribute override)
   ========================================================================== */
[hidden],
.is-hidden {
  display: none !important;
}