/* =================================
   MAIN.CSS — Variables, reset, base
   DeloneTech Design System v2
   ================================= */

/* =================================
   INTER FONT — self-hosted
   ================================= */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/static/fonts/inter-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/static/fonts/inter-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/static/fonts/inter-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/static/fonts/inter-700.woff2') format('woff2');
}

/* =================================
   VARIABLES — DARK MODE (default)
   ================================= */
:root {
  /* ── Backgrounds (blue-tinted darks — landing style) ── */
  --bg-body:      #0f0f19;
  --bg-primary:   #13131f;
  --bg-secondary: #1a1a28;
  --bg-card:      #1e1e2c;
  --bg-elevated:  #262638;
  --bg-tertiary:  #1c1c2a;
  --bg-nav:       rgba(15, 15, 25, 0.92);

  /* ── Text ────────────────────────── */
  --text-primary:   #ffffff;
  --text-secondary: #e0e0ea;
  --text-tertiary:  #b0b0c0;

  /* ── Borders ─────────────────────── */
  --border-color:  #2a2a3c;
  --border-subtle: #20202e;
  --border-bright: #3c3c50;

  /* ── Accent (naranja DeloneTech) ─── */
  --accent:            #d4762c;
  --accent-hover:      #e88535;
  --accent-dim:        #b06020;
  --accent-muted:      rgba(212, 118, 44, 0.10);
  --accent-muted-mid:  rgba(212, 118, 44, 0.18);
  --accent-glow:       0 0 24px rgba(212, 118, 44, 0.28);
  --accent-glow-sm:    0 0 12px rgba(212, 118, 44, 0.18);

  /* ── Gradients ───────────────────── */
  --gradient-accent:   linear-gradient(135deg, #c46d28 0%, #e8883a 100%);
  --gradient-surface:  linear-gradient(180deg, #1e1e2c 0%, #161624 100%);
  --gradient-card:     linear-gradient(160deg, #20202e 0%, #1a1a28 100%);

  /* ── Buttons ─────────────────────── */
  --btn-primary-bg:         #ededf0;
  --btn-primary-text:       #0f0f19;
  --btn-primary-hover-bg:   #ffffff;
  --btn-secondary-bg:       transparent;
  --btn-secondary-text:     #b8b8c4;
  --btn-secondary-border:   #333346;
  --btn-secondary-hover-bg: rgba(237, 237, 240, 0.06);

  /* ── Form ────────────────────────── */
  --input-bg:           #1a1a28;
  --input-border:       #2a2a3c;
  --input-focus-border: #d4762c;
  --input-text:         #ededf0;
  --input-placeholder:  #484860;

  /* ── Shadows ─────────────────────── */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.5), 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.55), 0 2px 6px rgba(0,0,0,0.4);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.65), 0 4px 16px rgba(0,0,0,0.45);
  --shadow-xl: 0 32px 80px rgba(0,0,0,0.75);

  /* ── Status ──────────────────────── */
  --color-success: #22c55e;
  --color-warning: #f59e0b;
  --color-error:   #ef4444;
  --color-info:    #3b82f6;

  /* ── Layout ──────────────────────── */
  --nav-height:    60px;
  --sidebar-width: 252px;
  --radius-xs:     4px;
  --radius-sm:     7px;
  --radius:        11px;
  --radius-md:     13px;
  --radius-lg:     16px;
  --radius-xl:     22px;
  --radius-full:   9999px;
  --transition:    0.18s ease;

  /* ── Font ────────────────────────── */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* ── Alias ─────────────────────── */
  --color-accent: var(--accent);
}

/* =================================
   VARIABLES — LIGHT MODE
   ================================= */
[data-theme="light"] {
  --bg-body:      #f0efea;
  --bg-primary:   #f5f4ef;
  --bg-secondary: #ece9e2;
  --bg-card:      #ffffff;
  --bg-elevated:  #f8f7f2;
  --bg-tertiary:  #e8e6e0;
  --bg-nav:       rgba(245, 244, 239, 0.94);

  --text-primary:   #18180f;
  --text-secondary: #5a5a52;
  --text-tertiary:  #9a9a90;

  --border-color:  #d8d5cc;
  --border-subtle: #e8e5dc;
  --border-bright: #c0bdb4;

  --accent:           #c46d28;
  --accent-hover:     #b05e20;
  --accent-dim:       #a05818;
  --accent-muted:     rgba(196, 109, 40, 0.08);
  --accent-muted-mid: rgba(196, 109, 40, 0.14);
  --accent-glow:      0 0 24px rgba(196, 109, 40, 0.18);
  --accent-glow-sm:   0 0 12px rgba(196, 109, 40, 0.12);

  --gradient-accent:   linear-gradient(135deg, #c46d28 0%, #e07830 100%);
  --gradient-surface:  linear-gradient(180deg, #f5f4ef 0%, #eeeae2 100%);
  --gradient-card:     linear-gradient(160deg, #ffffff 0%, #f8f6f0 100%);

  --btn-primary-bg:         #18180f;
  --btn-primary-text:       #f5f4ef;
  --btn-primary-hover-bg:   #2a2a20;
  --btn-secondary-bg:       transparent;
  --btn-secondary-text:     #38382e;
  --btn-secondary-border:   #d0cdc4;
  --btn-secondary-hover-bg: rgba(24, 24, 15, 0.05);

  --input-bg:           #ffffff;
  --input-border:       #d0cdc4;
  --input-focus-border: #c46d28;
  --input-text:         #18180f;
  --input-placeholder:  #9a9a90;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.05);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.12), 0 4px 16px rgba(0,0,0,0.07);
  --shadow-xl: 0 32px 80px rgba(0,0,0,0.16);

  --color-accent: var(--accent);
}

/* =================================
   Reset & Base
   ================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: none;
  text-rendering: optimizeSpeed;
}

/* Scrollbar — thin and themed */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--bg-elevated) transparent;
}
*::-webkit-scrollbar { width: 5px; height: 5px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 9px; }
*::-webkit-scrollbar-thumb:hover { background: var(--border-bright); }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--accent-hover); }

img { max-width: 100%; }

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 0.5rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
h4 { font-size: 0.95rem; }

p { margin: 0 0 1rem; }

hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 1.5rem 0;
}

/* =================================
   Utilities
   ================================= */
.text-primary    { color: var(--text-primary) !important; }
.text-secondary  { color: var(--text-secondary) !important; }
.text-muted      { color: var(--text-tertiary) !important; }
.text-accent     { color: var(--accent) !important; }
.text-success    { color: var(--color-success) !important; }
.text-danger     { color: var(--color-error) !important; }
.text-warning    { color: var(--color-warning) !important; }
.text-sm  { font-size: 0.8125rem; }
.text-xs  { font-size: 0.72rem; }
.text-lg  { font-size: 1.05rem; }
.font-bold      { font-weight: 700; }
.font-semibold  { font-weight: 600; }
.font-medium    { font-weight: 500; }

.d-flex    { display: flex; }
.d-none    { display: none; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 1.25rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.ml-auto { margin-left: auto; }

.content-section + .content-section { margin-top: 2rem; }


.w-full   { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* =================================
   ACCESSIBILITY
   ================================= */

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

/* Skip to main content link */
.skip-link {
  position: fixed;
  top: -100px; left: 1rem;
  z-index: 9999;
  padding: 0.75rem 1.25rem;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: top 0.2s;
  box-shadow: var(--shadow-lg);
}
.skip-link:focus { top: 1rem; outline: 3px solid #fff; outline-offset: 2px; }

/* ── Focus-visible: keyboard nav ring ──────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius-xs);
}
/* Remove default outline for mouse users */
:focus:not(:focus-visible) { outline: none; }

/* Buttons and interactive controls */
.btn:focus-visible,
.nav-link:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* =================================
   REDUCED MOTION
   ================================= */
@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;
  }
  .skeleton { animation: none; background: var(--bg-tertiary); }
}

/* =================================
   ANIMATION UTILITIES
   ================================= */
@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slide-in-right {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212,118,44,0); }
  50%       { box-shadow: 0 0 0 6px rgba(212,118,44,0.18); }
}

.animate-fade-in       { animation: fade-in 0.25s ease both; }
.animate-slide-right   { animation: slide-in-right 0.22s ease both; }
.animate-shake         { animation: shake 0.4s ease; }

/* =================================
   SPINNER / LOADING
   ================================= */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2.5px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  flex-shrink: 0;
}
.spinner-sm { width: 14px; height: 14px; border-width: 2px; }
.spinner-lg { width: 28px; height: 28px; border-width: 3px; }

/* Button loading state */
.btn.loading {
  pointer-events: none;
  opacity: 0.75;
}
.btn.loading::after {
  content: '';
  display: inline-block;
  width: 13px; height: 13px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 0.4rem;
  vertical-align: middle;
}

/* Full-page loading overlay */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(15,15,25,0.6);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  z-index: 9998;
}
.loading-overlay .spinner { width: 40px; height: 40px; border-width: 4px; }

/* =================================
   TOOLTIP
   ================================= */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s;
  transform: translateX(-50%) translateY(4px);
  z-index: 1000;
}
[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
/* Tooltip bottom variant */
[data-tooltip-pos="bottom"]::after {
  bottom: auto;
  top: calc(100% + 8px);
  transform: translateX(-50%) translateY(-4px);
}
[data-tooltip-pos="bottom"]:hover::after { transform: translateX(-50%) translateY(0); }

/* =================================
   CUSTOM FORM CONTROLS
   ================================= */
/* Custom checkbox */
.checkbox-wrapper {
  display: flex; align-items: center; gap: 0.5rem;
  cursor: pointer; user-select: none;
}
.checkbox-wrapper input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-xs);
  background: var(--input-bg);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
  position: relative;
}
.checkbox-wrapper input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.checkbox-wrapper input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  top: 2px; left: 5px;
  width: 4px; height: 8px;
  border: 2px solid #fff;
  border-top: none; border-left: none;
  transform: rotate(45deg);
}
.checkbox-wrapper input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Custom radio */
.radio-wrapper {
  display: flex; align-items: center; gap: 0.5rem;
  cursor: pointer; user-select: none;
}
.radio-wrapper input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border: 1.5px solid var(--input-border);
  border-radius: 50%;
  background: var(--input-bg);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
  position: relative;
}
.radio-wrapper input[type="radio"]:checked {
  border-color: var(--accent);
  border-width: 4px;
  background: var(--accent);
  box-shadow: inset 0 0 0 3px var(--input-bg);
}
.radio-wrapper input[type="radio"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* =================================
   FORM ERROR FEEDBACK
   ================================= */
.form-field.has-error input,
.form-field.has-error select,
.form-field.has-error textarea {
  border-color: var(--color-error) !important;
  animation: shake 0.4s ease;
}
.form-field.has-error .form-label { color: var(--color-error); }

/* =================================
   SCROLL SHADOW (indica overflow)
   ================================= */
.scroll-shadow {
  background:
    linear-gradient(var(--bg-card) 30%, transparent) center top,
    linear-gradient(transparent, var(--bg-card) 70%) center bottom,
    radial-gradient(farthest-side at 50% 0, rgba(0,0,0,0.25), transparent) center top,
    radial-gradient(farthest-side at 50% 100%, rgba(0,0,0,0.25), transparent) center bottom;
  background-repeat: no-repeat;
  background-size: 100% 40px, 100% 40px, 100% 14px, 100% 14px;
  background-attachment: local, local, scroll, scroll;
}

/* =================================
   High contrast / forced colors
   ================================= */
@media (forced-colors: active) {
  .btn { border: 2px solid ButtonText !important; }
  .badge { border: 1px solid ButtonText !important; }
  .card { border: 1px solid CanvasText !important; }
  .form-control, .form-select, select, input, textarea {
    border: 1px solid ButtonText !important;
  }
  .alert { border: 2px solid CanvasText !important; }
  .table th, .table td { border: 1px solid CanvasText !important; }
  :focus-visible { outline: 3px solid Highlight !important; }
}
