/* ─────────────────────────────────────────────────────────────────
   public/tickets/styles.css — GNETICS Tickets UI
   Direction: DARK EDITORIAL BRUTALIST TECH
   Palette: Electric green terminal (#00FF41) sur noir pur (#050505)
   Fonts: JetBrains Mono (display) + Inter Tight (body)
   ───────────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Inter+Tight:wght@400;500;600&display=swap');

:root {
  /* Colors */
  --bg-primary: #050505;
  --bg-secondary: #0D0D0D;
  --bg-card: #141414;
  --bg-elevated: #1A1A1A;
  --border: rgba(0, 255, 65, 0.08);
  --border-hover: rgba(0, 255, 65, 0.2);

  --text-primary: #F8F8F8;
  --text-secondary: #6B7280;
  --text-muted: #4B5563;

  --accent: #00FF41;
  --accent-dim: rgba(0, 255, 65, 0.6);
  --accent-glow: rgba(0, 255, 65, 0.15);

  /* Status colors - brutalist palette */
  --status-open: #6B7280;
  --status-in-progress: #00FF41;
  --status-done: #10B981;
  --status-blocked: #F59E0B;
  --status-cancelled: #EF4444;
  --status-failed: #DC2626;

  /* Priority colors */
  --priority-high: #EF4444;
  --priority-normal: #6B7280;
  --priority-low: #10B981;

  /* Typography */
  --font-display: 'JetBrains Mono', monospace;
  --font-body: 'Inter Tight', sans-serif;

  /* Spacing */
  --spacing-unit: 8px;
}

/* ─────── Reset & Base ─────── */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  font-size: 15px;
  position: relative;
  overflow-x: hidden;
}

/* Grain overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

/* ─────── Header (sticky) ─────── */

header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(5, 5, 5, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: calc(var(--spacing-unit) * 2) calc(var(--spacing-unit) * 3);
}

header h1 {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  font-weight: 700;
  color: var(--accent);
  margin-bottom: calc(var(--spacing-unit) * 1.5);
  letter-spacing: -0.02em;
  text-transform: uppercase;
}

.counters {
  display: flex;
  gap: calc(var(--spacing-unit) * 1.5);
  flex-wrap: wrap;
}

.counter {
  padding: calc(var(--spacing-unit) * 0.75) calc(var(--spacing-unit) * 1.5);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-display);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.counter:hover {
  border-color: var(--border-hover);
  box-shadow: 0 0 16px var(--accent-glow);
}

.counter.open { color: var(--status-open); }
.counter.in_progress { color: var(--status-in-progress); }
.counter.done { color: var(--status-done); }
.counter.blocked { color: var(--status-blocked); }
.counter.cancelled, .counter.failed { color: var(--status-cancelled); }

/* ─────── Layout ─────── */

.container {
  display: flex;
  min-height: calc(100vh - 120px);
}

/* ─────── Sidebar (filters) ─────── */

aside {
  width: 280px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: calc(var(--spacing-unit) * 3);
  overflow-y: auto;
}

aside h2 {
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: calc(var(--spacing-unit) * 2);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.filter-group {
  margin-bottom: calc(var(--spacing-unit) * 3);
}

.filter-group > label {
  display: block;
  font-family: var(--font-display);
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: calc(var(--spacing-unit) * 1);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.filter-group input[type="text"],
.filter-group select {
  width: 100%;
  padding: calc(var(--spacing-unit) * 1.5);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.875rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  outline: none;
}

.filter-group input[type="text"]:focus,
.filter-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 255, 65, 0.1);
}

.filter-group input[type="text"]::placeholder {
  color: var(--text-muted);
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: calc(var(--spacing-unit) * 1);
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: calc(var(--spacing-unit) * 1);
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--text-primary);
  cursor: pointer;
  padding: calc(var(--spacing-unit) * 0.5);
  border-radius: 4px;
  transition: background 0.15s ease;
}

.checkbox-group label:hover {
  background: rgba(255, 255, 255, 0.03);
}

.checkbox-group input[type="checkbox"] {
  cursor: pointer;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

/* ─────── Main content ─────── */

main {
  flex: 1;
  padding: calc(var(--spacing-unit) * 3);
  overflow-y: auto;
}

/* ─────── Tickets grid ─────── */

.tickets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: calc(var(--spacing-unit) * 2);
}

.ticket-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: calc(var(--spacing-unit) * 2);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 1;
  will-change: transform, opacity;
}

.ticket-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 255, 65, 0.08), 0 0 40px rgba(0, 255, 65, 0.04);
}

.ticket-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: calc(var(--spacing-unit) * 1.5);
  gap: calc(var(--spacing-unit) * 1);
}

.ticket-number {
  font-family: var(--font-display);
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.05em;
}

.badges {
  display: flex;
  gap: calc(var(--spacing-unit) * 0.75);
  flex-wrap: wrap;
  align-items: center;
}

.badge {
  font-family: var(--font-display);
  font-size: 0.6875rem;
  padding: calc(var(--spacing-unit) * 0.5) calc(var(--spacing-unit) * 1);
  border-radius: 3px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.badge.status-open {
  background: rgba(107, 114, 128, 0.15);
  color: var(--status-open);
  border-color: rgba(107, 114, 128, 0.3);
}
.badge.status-in_progress {
  background: rgba(0, 255, 65, 0.15);
  color: var(--accent);
  border-color: rgba(0, 255, 65, 0.3);
}
.badge.status-done {
  background: rgba(16, 185, 129, 0.15);
  color: var(--status-done);
  border-color: rgba(16, 185, 129, 0.3);
}
.badge.status-blocked {
  background: rgba(245, 158, 11, 0.15);
  color: var(--status-blocked);
  border-color: rgba(245, 158, 11, 0.3);
}
.badge.status-cancelled,
.badge.status-failed {
  background: rgba(239, 68, 68, 0.15);
  color: var(--status-cancelled);
  border-color: rgba(239, 68, 68, 0.3);
}

.badge.priority-high {
  background: rgba(239, 68, 68, 0.15);
  color: var(--priority-high);
  border-color: rgba(239, 68, 68, 0.3);
}
.badge.priority-normal {
  background: rgba(107, 114, 128, 0.15);
  color: var(--priority-normal);
  border-color: rgba(107, 114, 128, 0.3);
}
.badge.priority-low {
  background: rgba(16, 185, 129, 0.15);
  color: var(--priority-low);
  border-color: rgba(16, 185, 129, 0.3);
}

.badge.role, .badge.project {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border-color: rgba(255, 255, 255, 0.1);
}

.ticket-title {
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font-body);
  margin-bottom: calc(var(--spacing-unit) * 1);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text-primary);
}

.ticket-meta {
  font-family: var(--font-display);
  font-size: 0.6875rem;
  color: var(--text-secondary);
  margin-top: calc(var(--spacing-unit) * 1);
  letter-spacing: 0.02em;
}

/* ─────── Detail panel (slide-in) ─────── */

#detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 50%;
  max-width: 700px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 200;
  overflow-y: auto;
  padding: calc(var(--spacing-unit) * 3);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.5);
}

#detail-panel.open {
  transform: translateX(0);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: calc(var(--spacing-unit) * 3);
}

.panel-close {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s ease;
  font-family: var(--font-display);
}

.panel-close:hover {
  background: var(--bg-elevated);
  border-color: var(--border-hover);
  color: var(--accent);
}

.panel-title {
  font-size: 1.5rem;
  font-weight: 700;
  font-family: var(--font-body);
  margin-bottom: calc(var(--spacing-unit) * 1);
  line-height: 1.3;
}

.panel-number {
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 700;
  margin-bottom: calc(var(--spacing-unit) * 2);
  letter-spacing: 0.05em;
}

.panel-section {
  margin-bottom: calc(var(--spacing-unit) * 3);
}

.panel-section h3 {
  font-family: var(--font-display);
  font-size: 0.75rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: calc(var(--spacing-unit) * 1.5);
}

.panel-section .content {
  background: var(--bg-primary);
  padding: calc(var(--spacing-unit) * 2);
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 0.875rem;
  line-height: 1.7;
  white-space: pre-wrap;
  font-family: var(--font-body);
}

.panel-meta {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: calc(var(--spacing-unit) * 1.5);
  font-size: 0.875rem;
}

.panel-meta-item {
  background: var(--bg-primary);
  padding: calc(var(--spacing-unit) * 1.5);
  border-radius: 6px;
  border: 1px solid var(--border);
  transition: border-color 0.2s ease;
}

.panel-meta-item:hover {
  border-color: var(--border-hover);
}

.panel-meta-item strong {
  display: block;
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: calc(var(--spacing-unit) * 0.5);
}

/* ─────── States (loading, empty, error) ─────── */

.loading {
  text-align: center;
  padding: calc(var(--spacing-unit) * 6);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 0.875rem;
  letter-spacing: 0.05em;
}

.empty {
  text-align: center;
  padding: calc(var(--spacing-unit) * 6);
  color: var(--text-secondary);
}

.empty::before {
  content: '∅';
  display: block;
  font-size: 4rem;
  font-family: var(--font-display);
  color: var(--accent-dim);
  margin-bottom: calc(var(--spacing-unit) * 2);
  opacity: 0.3;
}

.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #FCA5A5;
  padding: calc(var(--spacing-unit) * 2);
  border-radius: 6px;
  margin: calc(var(--spacing-unit) * 3);
  font-family: var(--font-display);
  font-size: 0.875rem;
}

/* ─────── Auth modal ─────── */

#auth-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}

#auth-modal.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-secondary);
  padding: calc(var(--spacing-unit) * 4);
  border-radius: 8px;
  border: 1px solid var(--border);
  max-width: 420px;
  width: 90%;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
}

.modal-content h2 {
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 1.25rem;
  margin-bottom: calc(var(--spacing-unit) * 1.5);
  letter-spacing: -0.01em;
}

.modal-content p {
  margin-bottom: calc(var(--spacing-unit) * 2);
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.modal-content p code {
  background: var(--bg-primary);
  padding: calc(var(--spacing-unit) * 0.5) calc(var(--spacing-unit) * 1);
  border-radius: 3px;
  font-family: var(--font-display);
  font-size: 0.8125rem;
  color: var(--accent);
}

.modal-content input {
  width: 100%;
  padding: calc(var(--spacing-unit) * 1.5);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 0.875rem;
  margin-bottom: calc(var(--spacing-unit) * 2);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  outline: none;
}

.modal-content input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 255, 65, 0.1);
}

.modal-content button {
  width: 100%;
  padding: calc(var(--spacing-unit) * 1.5);
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: var(--bg-primary);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.875rem;
  cursor: pointer;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.modal-content button::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.1);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.modal-content button:hover {
  background: var(--accent-dim);
  box-shadow: 0 4px 20px rgba(0, 255, 65, 0.3);
}

.modal-content button:hover::before {
  opacity: 1;
}

.modal-content button:active {
  transform: translateY(1px);
}

/* ─────── Responsive (mobile-first) ─────── */

@media (max-width: 768px) {
  :root {
    --spacing-unit: 6px;
  }

  header {
    padding: calc(var(--spacing-unit) * 2);
  }

  header h1 {
    font-size: 1.125rem;
    margin-bottom: calc(var(--spacing-unit) * 1);
  }

  .counters {
    gap: calc(var(--spacing-unit) * 1);
  }

  .counter {
    font-size: 0.75rem;
    padding: calc(var(--spacing-unit) * 0.75) calc(var(--spacing-unit) * 1.25);
  }

  .container {
    flex-direction: column;
  }

  aside {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: calc(var(--spacing-unit) * 2);
  }

  aside h2 {
    font-size: 0.8125rem;
  }

  main {
    padding: calc(var(--spacing-unit) * 2);
  }

  .tickets-grid {
    grid-template-columns: 1fr;
    gap: calc(var(--spacing-unit) * 2);
  }

  #detail-panel {
    width: 100%;
    max-width: 100%;
    padding: calc(var(--spacing-unit) * 2);
  }

  .panel-meta {
    grid-template-columns: 1fr;
  }

  .modal-content {
    padding: calc(var(--spacing-unit) * 3);
  }

  /* Touch targets minimum 44px */
  button, .panel-close, .counter {
    min-height: 44px;
    min-width: 44px;
  }
}

/* ─────── Accessibility ─────── */

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

/* ─────── Print ─────── */

@media print {
  body::after,
  header,
  aside,
  #detail-panel,
  #auth-modal {
    display: none !important;
  }

  .ticket-card {
    page-break-inside: avoid;
    border: 1px solid #000;
    margin-bottom: 1rem;
  }
}
