/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * Job Radar Design System - shadcn-inspired
 * With Propshaft, assets are served efficiently without preprocessing steps.
 */

@layer base {
  :root {
    /* Background colors */
    --background: 0 0% 100%;           /* White */
    --foreground: 222.2 84% 4.9%;      /* Near black */

    /* Card colors */
    --card: 0 0% 100%;                 /* White */
    --card-foreground: 222.2 84% 4.9%; /* Near black */

    /* Popover colors */
    --popover: 0 0% 100%;              /* White */
    --popover-foreground: 222.2 84% 4.9%;

    /* Primary colors (Blue) */
    --primary: 221.2 83.2% 53.3%;      /* Blue-600 */
    --primary-foreground: 210 40% 98%; /* Near white */

    /* Secondary colors (Neutral) */
    --secondary: 210 40% 96.1%;        /* Gray-100 */
    --secondary-foreground: 222.2 47.4% 11.2%; /* Gray-900 */

    /* Muted colors */
    --muted: 210 40% 96.1%;            /* Gray-100 */
    --muted-foreground: 215.4 16.3% 46.9%; /* Gray-500 */

    /* Accent colors */
    --accent: 210 40% 96.1%;           /* Gray-100 */
    --accent-foreground: 222.2 47.4% 11.2%; /* Gray-900 */

    /* Destructive colors (Red) */
    --destructive: 0 84.2% 60.2%;      /* Red-500 */
    --destructive-foreground: 210 40% 98%; /* Near white */

    /* Border colors */
    --border: 214.3 31.8% 91.4%;       /* Gray-200 */
    --input: 214.3 31.8% 91.4%;        /* Gray-200 */
    --ring: 221.2 83.2% 53.3%;         /* Blue-600 */

    /* Semantic colors */
    --success: 142.1 76.2% 36.3%;      /* Green-600 */
    --success-foreground: 210 40% 98%;
    --warning: 38 92% 50%;             /* Yellow-500 */
    --warning-foreground: 222.2 47.4% 11.2%;
    --info: 199 89% 48%;               /* Sky-500 */
    --info-foreground: 210 40% 98%;

    /* Chart colors */
    --chart-1: 221.2 83.2% 53.3%;      /* Blue */
    --chart-2: 142.1 76.2% 36.3%;      /* Green */
    --chart-3: 38 92% 50%;             /* Yellow */
    --chart-4: 262.1 83.3% 57.8%;      /* Purple */
    --chart-5: 346.8 77.2% 49.8%;      /* Red */

    /* Radius */
    --radius: 0.5rem;                  /* 8px */
  }

  .dark {
    /* Background colors — CodeCrafters slate palette */
    --background: 222 47% 8%;          /* slate-950: deepest dark */
    --foreground: 210 40% 98%;         /* near white */

    /* Card colors */
    --card: 218 38% 14%;               /* gray-850: elevated surface */
    --card-foreground: 210 40% 98%;    /* near white */

    /* Popover colors */
    --popover: 217 33% 18%;            /* slate-800 */
    --popover-foreground: 210 40% 98%;

    /* Primary colors — Teal (CodeCrafters brand accent) */
    --primary: 182 55% 50%;            /* teal-500 */
    --primary-foreground: 222 47% 8%;  /* dark bg on teal button */

    /* Secondary colors */
    --secondary: 215 25% 27%;          /* slate-700 */
    --secondary-foreground: 210 40% 98%;

    /* Muted colors */
    --muted: 217 33% 18%;              /* slate-800 */
    --muted-foreground: 215 20% 65%;   /* slate-400 / #94a3b8 */

    /* Accent colors */
    --accent: 215 25% 27%;             /* slate-700 */
    --accent-foreground: 210 40% 98%;

    /* Destructive colors */
    --destructive: 0 72% 51%;          /* red-500 */
    --destructive-foreground: 210 40% 98%;

    /* Border / input / ring */
    --border: 215 25% 27%;             /* slate-700 */
    --input: 215 25% 27%;              /* slate-700 */
    --ring: 182 55% 50%;               /* teal-500 */

    /* Semantic colors */
    --success: 142 60% 40%;            /* green-500 */
    --success-foreground: 210 40% 98%;
    --warning: 45 90% 52%;             /* yellow-400 */
    --warning-foreground: 222 47% 8%;
    --info: 198 75% 48%;               /* sky-400 */
    --info-foreground: 210 40% 98%;

    /* Chart colors */
    --chart-1: 182 55% 50%;            /* teal */
    --chart-2: 142 60% 40%;            /* green */
    --chart-3: 45 90% 52%;             /* yellow */
    --chart-4: 262 83% 58%;            /* purple */
    --chart-5: 0 72% 51%;              /* red */
  }
}

@layer base {
  * {
    @apply border-border;
  }

  body {
    @apply bg-background text-foreground;
    font-family: Montserrat, system-ui, sans-serif;
    font-feature-settings: "rlig" 1, "calt" 1;
  }
}

/* Mobile overflow fix: prevent horizontal scrolling */
html, body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* Responsive table wrapper for wide tables on mobile */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Screen reader only utility class for accessibility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Smooth theme transitions */
body,
nav,
main,
footer,
.card,
button,
input,
select,
textarea {
  transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out, color 0.2s ease-in-out;
}

/* View toggle: compact/detailed card switching — default to detailed */
.job-card-compact {
  display: none;
}

[data-view-mode="compact"] .job-card-detailed {
  display: none;
}

[data-view-mode="compact"] .job-card-compact {
  display: block;
}

/* ============================================================================
   SIDEBAR LAYOUT SYSTEM
   ============================================================================ */

:root {
  --sidebar-width: 220px;
  --sidebar-collapsed-width: 44px;
  --topbar-height: 42px;
}

/* Top bar — fixed, always on top */
.app-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  z-index: 50;
  background: hsl(var(--background) / 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid hsl(var(--border) / 0.4);
  display: flex;
  align-items: center;
  padding: 0 1rem;
}

/* App shell — flex row beneath topbar */
.app-shell {
  display: flex;
  padding-top: var(--topbar-height);
  min-height: 100vh;
}

/* Sidebar — fixed left column */
.app-sidebar {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: hsl(var(--card));
  border-right: 1px solid hsl(var(--border));
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 40;
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease-in-out;
}

/* Main content — offset by sidebar */
.app-main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
  transition: margin-left 0.2s ease-in-out;
}

/* Sidebar nav link */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  transition: background-color 0.15s, color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-decoration: none;
}

.sidebar-link:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.sidebar-link.active {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
  font-weight: 600;
}

.sidebar-link svg {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
}

/* Sidebar label — hides when collapsed */
.sidebar-label {
  opacity: 1;
  transition: opacity 0.15s ease-in-out;
  overflow: hidden;
}

/* Sidebar group label */
.sidebar-group-label {
  padding: 0.5rem 0.75rem 0.25rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: hsl(var(--muted-foreground));
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.15s ease-in-out;
}

/* Sidebar group divider */
.sidebar-divider {
  height: 1px;
  background: hsl(var(--border));
  margin: 0.5rem 0.75rem;
}

/* Desktop collapsed state */
@media (min-width: 1024px) {
  [data-sidebar-state="collapsed"] .app-sidebar {
    width: var(--sidebar-collapsed-width);
  }

  [data-sidebar-state="collapsed"] .app-main {
    margin-left: var(--sidebar-collapsed-width);
  }

  [data-sidebar-state="collapsed"] .sidebar-label,
  [data-sidebar-state="collapsed"] .sidebar-group-label {
    opacity: 0;
    width: 0;
    overflow: hidden;
  }

  [data-sidebar-state="collapsed"] .sidebar-link {
    justify-content: center;
    padding: 0.5rem;
    overflow: visible;
    gap: 0;
  }

  [data-sidebar-state="collapsed"] .sidebar-link svg {
    margin: 0;
  }
}

/* Mobile: sidebar is off-screen by default, slides in as overlay */
@media (max-width: 1023px) {
  .app-sidebar {
    width: var(--sidebar-width);
    transform: translateX(-100%);
    transition: transform 0.2s ease-in-out;
    z-index: 60;
  }

  .app-main {
    margin-left: 0;
  }

  [data-sidebar-mobile="open"] .app-sidebar {
    transform: translateX(0);
  }

  /* Backdrop for mobile overlay */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    top: var(--topbar-height);
    background: rgba(0, 0, 0, 0.5);
    z-index: 55;
  }

  [data-sidebar-mobile="open"] .sidebar-backdrop {
    display: block;
  }
}

/* Unauthenticated: no sidebar offset */
body:not([data-authenticated]) .app-main {
  margin-left: 0;
}

/* Sidebar toggle button at bottom */
.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  margin-top: auto;
  border-top: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
  font-size: 0.8125rem;
  background: none;
  border-left: none;
  border-right: none;
  border-bottom: none;
  width: 100%;
}

.sidebar-collapse-btn:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.sidebar-collapse-btn svg {
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  transition: transform 0.2s ease-in-out;
}

[data-sidebar-state="collapsed"] .sidebar-collapse-btn svg {
  transform: rotate(180deg);
}

[data-sidebar-state="collapsed"] .sidebar-collapse-btn .sidebar-label {
  display: none;
}

/* ============================================================================
   PREFERENCES PAGE — SECONDARY SIDEBAR LAYOUT
   ============================================================================ */

.preferences-layout {
  display: flex;
  gap: 0;
  min-height: calc(100vh - var(--topbar-height) - 4rem);
}

.preferences-sidebar {
  width: 180px;
  flex-shrink: 0;
  padding: 1.5rem 0 1.5rem 0;
  border-right: 1px solid hsl(var(--border) / 0.5);
  margin-right: 2rem;
}

.preferences-content {
  flex: 1;
  min-width: 0;
  max-width: 52rem;
  padding-top: 0.5rem;
}

.preferences-nav-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.625rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.8125rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  transition: background-color 0.15s, color 0.15s;
  text-decoration: none;
  cursor: pointer;
}

.preferences-nav-link:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.preferences-nav-link.active {
  background: hsl(var(--accent));
  color: hsl(var(--foreground));
  font-weight: 600;
}

/* Mobile: stack sidebar above content */
@media (max-width: 768px) {
  .preferences-layout {
    flex-direction: column;
  }

  .preferences-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid hsl(var(--border) / 0.5);
    margin-right: 0;
    margin-bottom: 1.5rem;
    padding: 0 0 0.75rem 0;
  }

  .preferences-sidebar nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.25rem;
  }

  .preferences-sidebar > div > p {
    display: none;
  }

  .preferences-nav-link {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
  }

  .preferences-nav-link svg {
    display: none;
  }
}

/* ============================================================================
   JOB SHOW — FLOATING BOTTOM BAR
   ============================================================================ */

.job-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  margin-left: var(--sidebar-width);
  background: hsl(var(--card));
  border-top: 1px solid hsl(var(--border));
  padding: 0.5rem 1.5rem;
  padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  transition: margin-left 0.2s ease-in-out;
}

@media (min-width: 1024px) {
  [data-sidebar-state="collapsed"] .job-bottom-bar {
    margin-left: var(--sidebar-collapsed-width);
  }
}

@media (max-width: 1023px) {
  .job-bottom-bar {
    margin-left: 0;
    padding: 0.5rem 1rem;
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
  }
}

/* Horizontal pipeline stepper */
.pipeline-h {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.pipeline-h::-webkit-scrollbar {
  display: none;
}

.pipeline-h-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.pipeline-h-step button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.pipeline-h-circle {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}

.pipeline-h-line {
  width: 2rem;
  height: 2px;
  flex-shrink: 0;
  align-self: center;
  margin-top: -0.75rem;
}

.pipeline-h-label {
  font-size: 0.625rem;
  font-weight: 500;
  white-space: nowrap;
  line-height: 1;
}

@media (max-width: 639px) {
  .pipeline-h-label {
    display: none;
  }
}

/* Bottom bar action buttons */
.bottom-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

@media (max-width: 639px) {
  .bottom-bar-actions .btn-label {
    display: none;
  }
}
