/**
 * Rack Auditor — Custom styles
 * UI Implementer owns this file.
 * Steel blue datacenter color scheme. Tailwind handles most layout and theming.
 *
 * Fallback: ensure .hidden works even if Tailwind CDN fails to load
 */
.hidden { display: none !important; }
/*
 * Color tokens (CSS custom properties):
 *   --ra-primary   #1e3a5f  deep steel blue
 *   --ra-accent    #3b82f6  electric blue (Tailwind blue-500)
 *   --ra-muted     #94a3b8  slate-400
 */

/* ── Font ──────────────────────────────────────────────────────────────────── */

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

code, .font-mono {
  font-family: 'JetBrains Mono', 'Fira Mono', 'Cascadia Code', monospace;
}

/* ── CSS custom properties — light mode ────────────────────────────────────── */

:root {
  --ra-primary:        #1e3a5f;
  --ra-accent:         #3b82f6;
  --ra-accent-hover:   #2563eb;
  --ra-muted:          #64748b;
  --ra-bg:             #f0f4f8;
  --ra-surface:        #ffffff;
  --ra-surface-raised: #e8eef4;
  --ra-border:         #cbd5e1;
  --ra-heading:        #0f172a;
  --ra-text:           #1e293b;
}

/* ── CSS custom properties — dark mode ─────────────────────────────────────── */

.dark {
  --ra-primary:        #1e3a5f;
  --ra-accent:         #3b82f6;
  --ra-accent-hover:   #60a5fa;
  --ra-muted:          #94a3b8;
  --ra-bg:             #0b1929;
  --ra-surface:        #112240;
  --ra-surface-raised: #1a3354;
  --ra-border:         #1e3a5f;
  --ra-heading:        #e2e8f0;
  --ra-text:           #cbd5e1;
}

/* ── Tailwind utility bridging (use ra- prefixed classes in HTML) ─────────── */

.bg-ra-bg             { background-color: var(--ra-bg); }
.bg-ra-surface        { background-color: var(--ra-surface); }
.bg-ra-surface-raised { background-color: var(--ra-surface-raised); }
.bg-ra-accent         { background-color: var(--ra-accent); }
.text-ra-heading      { color: var(--ra-heading); }
.text-ra-text         { color: var(--ra-text); }
.text-ra-muted        { color: var(--ra-muted); }
.text-ra-accent       { color: var(--ra-accent); }
.border-ra-border     { border-color: var(--ra-border); }
.hover\:bg-ra-accent-hover:hover { background-color: var(--ra-accent-hover); }
.hover\:bg-ra-surface-raised:hover { background-color: var(--ra-surface-raised); }
.hover\:text-ra-accent:hover { color: var(--ra-accent); }
.hover\:text-ra-heading:hover { color: var(--ra-heading); }
.focus\:ring-ra-accent:focus { --tw-ring-color: var(--ra-accent); }
.focus-visible\:ring-ra-accent:focus-visible { --tw-ring-color: var(--ra-accent); }

/* ── Body token override ────────────────────────────────────────────────────── */

body {
  background-color: var(--ra-bg);
  color: var(--ra-text);
}

/* ── Drop zone ──────────────────────────────────────────────────────────────── */

.ra-drop-zone {
  border-color: var(--ra-border);
  background-color: var(--ra-surface);
  min-height: 180px;
  /* Large touch target — field tech friendly */
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.ra-drop-zone:hover {
  border-color: var(--ra-accent);
  background-color: var(--ra-surface-raised);
}

.ra-drop-zone--active {
  border-color: var(--ra-accent);
  background-color: var(--ra-surface-raised);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ra-accent) 15%, transparent);
}

.ra-drop-zone--has-file {
  border-style: solid;
  border-color: var(--ra-accent);
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}

/* ── Utilization bar ────────────────────────────────────────────────────────── */

.ra-util-bar-track {
  height: 10px;
  border-radius: 9999px;
  background-color: var(--ra-surface-raised);
  overflow: hidden;
}

.ra-util-bar {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  /* Default gradient — overridden by modifier classes */
  background: linear-gradient(90deg, #22c55e, #84cc16);
}

/* Green: < 60% — plenty of capacity */
.ra-util-bar--green {
  background: linear-gradient(90deg, #16a34a, #22c55e);
}

/* Amber: 60–85% — filling up */
.ra-util-bar--amber {
  background: linear-gradient(90deg, #d97706, #f59e0b);
}

/* Red: > 85% — near capacity */
.ra-util-bar--red {
  background: linear-gradient(90deg, #dc2626, #ef4444);
}

/* ── Panel table ────────────────────────────────────────────────────────────── */

.ra-panel-table thead tr {
  background-color: var(--ra-surface-raised);
}

.ra-panel-table th {
  padding: 0.625rem 1rem;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ra-muted);
  white-space: nowrap;
}

.ra-panel-table td {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--ra-text);
  border-top: 1px solid var(--ra-border);
}

.ra-panel-table tbody tr:hover td {
  background-color: var(--ra-surface-raised);
}

/* ── Scan animation (pulsing rack icon) ─────────────────────────────────────── */

@keyframes ra-scan {
  0%, 100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--ra-accent) 40%, transparent);
    opacity: 1;
  }
  50% {
    box-shadow: 0 0 0 10px color-mix(in srgb, var(--ra-accent) 0%, transparent);
    opacity: 0.7;
  }
}

.ra-scan-anim {
  animation: ra-scan 1.4s ease-in-out infinite;
}

/* ── Section fade-in transitions ────────────────────────────────────────────── */

@keyframes ra-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

#results-section,
#loading-section,
#rate-limit-section,
#auth-required-section,
#error-section {
  animation: ra-fade-in 0.2s ease-out;
}

#byok-modal:not(.hidden) {
  animation: ra-fade-in 0.15s ease-out;
}

/* ── Mobile — large touch targets for field use ─────────────────────────────── */

@media (max-width: 640px) {
  /* Analyze button fills width on mobile */
  #analyze-btn {
    width: 100%;
    max-width: none;
  }

  /* Bigger drop zone on mobile */
  .ra-drop-zone {
    min-height: 200px;
    padding-top: 3rem;
    padding-bottom: 3rem;
  }

  /* Panel table: allow horizontal scroll on small screens */
  .ra-panel-table th,
  .ra-panel-table td {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }

  /* Summary cards: 2-column on mobile */
  #summary-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── Reduced motion ──────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .ra-scan-anim {
    animation: none;
  }

  .ra-util-bar {
    transition: none;
  }

  #results-section,
  #loading-section,
  #rate-limit-section,
  #auth-required-section,
  #error-section,
  #byok-modal:not(.hidden) {
    animation: none;
  }
}

/* ── Print styles — field techs may print audit reports ─────────────────────── */

@media print {
  /* Remove interactive chrome */
  header,
  footer,
  #upload-section,
  #loading-section,
  #rate-limit-section,
  #auth-required-section,
  #error-section,
  #new-scan-btn,
  #download-csv-btn,
  #byok-modal,
  .print\:hidden {
    display: none !important;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 11pt;
  }

  #results-section {
    display: block !important;
  }

  /* Summary cards — horizontal strip */
  #summary-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
  }

  #summary-cards > div {
    border: 1pt solid #94a3b8;
    padding: 0.5rem;
    border-radius: 4pt;
  }

  /* Utilization bar — print a plain bar */
  .ra-util-bar-track {
    border: 1pt solid #94a3b8;
    background: #f0f0f0 !important;
  }

  .ra-util-bar {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  /* Panel table */
  .ra-panel-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
  }

  .ra-panel-table th,
  .ra-panel-table td {
    border: 1pt solid #94a3b8;
    padding: 4pt 6pt;
    font-size: 9pt;
    color: #000 !important;
  }

  .ra-panel-table thead tr {
    background: #e8eef4 !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  /* Avoid breaking table rows across pages */
  .ra-panel-table tr {
    page-break-inside: avoid;
  }

  /* Print header with app title */
  #results-section::before {
    content: 'Rack Auditor — Port Audit Report';
    display: block;
    font-size: 14pt;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: #1e3a5f;
  }

  /* Ensure observations print cleanly */
  #observations-section {
    page-break-before: auto;
  }

  a {
    text-decoration: none;
    color: inherit;
  }
}
