@import url('./design-tokens.css');

/* ==========================================================================
   DANTE OS ENTERPRISE v23.1 - OMNI-DEVICE UNIFIED DESIGN SYSTEM & THEME
   Supports: Smart TVs (4K/1080p), Laptops/Desktops, Tablets/iPads, Smartphones (iOS/Android)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. DESIGN TOKENS & GLOBAL CSS VARIABLES
   -------------------------------------------------------------------------- */
:root {
  /* Core Color Palette */
  --color-primary-gold: #f59e0b;
  --color-gold-hover: #d97706;
  --bg-dark-main: #090d16;
  --bg-dark-surface: #0f172a;
  --bg-card-surface: rgba(15, 23, 42, 0.88);
  --color-cyan-accent: #06b6d4;
  --color-cyan-hover: #0891b2;
  --color-purple-accent: #8b5cf6;
  --color-emerald-accent: #10b981;
  --color-rose-accent: #f43f5e;

  /* Radius Tokens */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-pill: 9999px;

  /* System Aliases */
  --dante-bg: var(--bg-dark-main);
  --dante-card-bg: var(--bg-card-surface);
  --dante-card-hover: rgba(30, 41, 59, 0.95);
  --dante-border: rgba(51, 65, 85, 0.6);
  --dante-border-accent: rgba(245, 158, 11, 0.4);
  --dante-gold: var(--color-primary-gold);
  --dante-gold-hover: var(--color-gold-hover);
  --dante-gold-glow: rgba(245, 158, 11, 0.25);
  --dante-cyan: var(--color-cyan-accent);
  --dante-cyan-hover: var(--color-cyan-hover);
  --dante-emerald: var(--color-emerald-accent);
  --dante-rose: var(--color-rose-accent);
  --dante-purple: var(--color-purple-accent);

  /* Text & Typography */
  --dante-text-main: #f8fafc;
  --dante-text-muted: #94a3b8;
  --dante-text-subtle: #64748b;
  --dante-font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --dante-font-mono: 'JetBrains Mono', monospace;
  --dante-font-display: 'Oswald', var(--dante-font-sans);

  /* Fluid Typography Clamps */
  --font-size-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --font-size-sm: clamp(0.8125rem, 0.75rem + 0.35vw, 0.95rem);
  --font-size-base: clamp(0.875rem, 0.8rem + 0.45vw, 1.05rem);
  --font-size-lg: clamp(1rem, 0.9rem + 0.65vw, 1.25rem);
  --font-size-xl: clamp(1.15rem, 1rem + 0.85vw, 1.5rem);
  --font-size-2xl: clamp(1.35rem, 1.1rem + 1.25vw, 1.85rem);
  --font-size-3xl: clamp(1.6rem, 1.3rem + 1.65vw, 2.4rem);
  --font-size-4xl: clamp(2rem, 1.5rem + 2.2vw, 3.2rem);

  /* Touch & Safe Areas */
  --min-touch-target: 48px;
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-left: env(safe-area-inset-left, 0px);
  --safe-area-right: env(safe-area-inset-right, 0px);
}

/* --------------------------------------------------------------------------
   2. UNIVERSAL RESIDUAL & OVERFLOW RESILIENCE RESETS
   -------------------------------------------------------------------------- */
*, ::before, ::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  overflow-x: hidden !important;
  max-width: 100vw;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--dante-font-sans);
  background-color: var(--bg-dark-main);
  color: var(--dante-text-main);
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-top: var(--safe-area-top);
  padding-bottom: var(--safe-area-bottom);
  padding-left: var(--safe-area-left);
  padding-right: var(--safe-area-right);
  line-height: 1.5;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-dark-main);
}
::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

/* --------------------------------------------------------------------------
   3. FLUID TYPOGRAPHY & HEADINGS
   -------------------------------------------------------------------------- */
h1, .h1-fluid {
  font-size: var(--font-size-3xl);
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.02em;
}

h2, .h2-fluid {
  font-size: var(--font-size-2xl);
  line-height: 1.25;
  font-weight: 700;
}

h3, .h3-fluid {
  font-size: var(--font-size-xl);
  line-height: 1.3;
  font-weight: 600;
}

p, span, label {
  font-size: var(--font-size-base);
}

.font-mono {
  font-family: var(--dante-font-mono) !important;
}

/* --------------------------------------------------------------------------
   4. BASE CARD COMPONENTS & GLASSMORPHISM
   -------------------------------------------------------------------------- */
.dante-card {
  background: var(--bg-card-surface);
  border: 1px solid var(--dante-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform, opacity;
}

@media (hover: hover) {
  .dante-card:hover {
    border-color: rgba(245, 158, 11, 0.35);
    box-shadow: 0 15px 30px -5px rgba(245, 158, 11, 0.12);
  }

  .dante-card-interactive {
    cursor: pointer;
  }

  .dante-card-interactive:hover {
    transform: translateY(-2px);
  }
}

/* Glassmorphism fallbacks */
@supports not (backdrop-filter: blur(10px)) {
  .dante-card, .master-hud, .opcion-card, .modal-overlay-blur {
    background: #0f172a !important;
  }
}

/* --------------------------------------------------------------------------
   5. BUTTONS, BADGES & ERGONOMIC TOUCH TARGETS
   -------------------------------------------------------------------------- */
button, .btn-dante, input, select, textarea {
  font-family: inherit;
  touch-action: manipulation;
}

.dante-btn-gold {
  background: linear-gradient(135deg, var(--color-primary-gold) 0%, var(--color-gold-hover) 100%);
  color: #0f172a;
  font-weight: 700;
  padding: 0.625rem 1.25rem;
  min-height: var(--min-touch-target);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3);
  transition: all 0.2s ease;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
}

@media (hover: hover) {
  .dante-btn-gold:hover {
    background: linear-gradient(135deg, #fbbf24 0%, var(--color-primary-gold) 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.45);
  }
}

.dante-btn-outline {
  background: rgba(15, 23, 42, 0.6);
  color: var(--dante-text-main);
  border: 1px solid var(--dante-border);
  font-weight: 600;
  padding: 0.625rem 1.25rem;
  min-height: var(--min-touch-target);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
}

@media (hover: hover) {
  .dante-btn-outline:hover {
    border-color: var(--color-primary-gold);
    color: var(--color-primary-gold);
    background: rgba(245, 158, 11, 0.08);
  }
}

.btn-logout-enterprise {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  min-height: 40px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-rose-accent);
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.25);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

@media (hover: hover) {
  .btn-logout-enterprise:hover {
    background: rgba(244, 63, 94, 0.2);
    border-color: rgba(244, 63, 94, 0.5);
    color: #fb7185;
    transform: translateY(-1px);
  }
}

/* Badges */
.dante-gold-badge {
  background: rgba(245, 158, 11, 0.12);
  color: var(--color-primary-gold);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  white-space: nowrap;
}

.dante-cyan-badge {
  background: rgba(6, 182, 212, 0.12);
  color: var(--color-cyan-accent);
  border: 1px solid rgba(6, 182, 212, 0.3);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  white-space: nowrap;
}

.dante-emerald-badge {
  background: rgba(16, 185, 129, 0.12);
  color: var(--dante-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   6. RESPONSIVE CONTAINER & OVERFLOW PROTECTION
   -------------------------------------------------------------------------- */
.table-container, .overflow-x-auto {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
}

.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.375rem 0;
  max-width: 100%;
}

.chart-box, .apexcharts-canvas {
  max-width: 100% !important;
  overflow: hidden !important;
}

/* --------------------------------------------------------------------------
   7. MODALS, OVERLAYS & MOBILE DRAWERS
   -------------------------------------------------------------------------- */
.modal-overlay-blur {
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  background: rgba(5, 8, 18, 0.85);
  transition: opacity 0.3s ease;
  padding: 1rem;
}

@keyframes dante-modal-scale-up {
  0% {
    opacity: 0;
    transform: scale(0.94) translateY(12px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-dialog-scale {
  animation: dante-modal-scale-up 280ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* --------------------------------------------------------------------------
   8. OMNI-DEVICE MEDIA QUERIES
   -------------------------------------------------------------------------- */

/* 📺 Smart TVs & Ultra-Wide 4K Displays (>= 1920px) */
@media (min-width: 1920px) {
  html {
    font-size: 18px;
  }

  .container-enterprise, body > div.max-w-7xl, body > div.max-w-6xl {
    max-width: 1800px !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  /* High contrast focus ring for Smart TV remote control / keyboard D-Pad */
  button:focus-visible, a:focus-visible, [tabindex]:focus-visible {
    outline: 3px solid var(--color-cyan-accent) !important;
    outline-offset: 4px !important;
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.8) !important;
  }

  .dante-card {
    padding: 2rem !important;
  }
}

@media (min-width: 2560px) {
  html {
    font-size: 22px;
  }

  .container-enterprise, body > div.max-w-7xl, body > div.max-w-6xl {
    max-width: 2300px !important;
  }
}

/* 💻 Laptops & Standard Desktops (1024px - 1919px) */
@media (min-width: 1024px) and (max-width: 1919px) {
  .grid-responsive-desktop {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1.5rem;
  }
}

/* 📱 Tablets & iPads (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
  html {
    font-size: 15px;
  }

  .modal-dialog-scale {
    max-width: 90vw !important;
    max-height: 85vh !important;
  }

  .grid-tablet-2col {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* 📱 Smartphones & Mobile Devices (< 768px) */
@media (max-width: 767px) {
  html {
    font-size: 14px;
  }

  body {
    padding-left: max(0.75rem, var(--safe-area-left));
    padding-right: max(0.75rem, var(--safe-area-right));
  }

  /* Ergonomic Touch Targets */
  button, .dante-btn-gold, .dante-btn-outline, input, select, textarea, .opcion-card {
    min-height: var(--min-touch-target) !important;
  }

  /* Universal Padding Scaling */
  .dante-card, .kpi-card, .war-room-card, .chart-box {
    padding: 0.875rem !important;
  }

  /* Convert grids to 1 column */
  .grid-responsive-mobile, .grid-cols-2, .grid-cols-3, .grid-cols-4 {
    grid-template-columns: 1fr !important;
  }

  /* Responsive Headers & Toolbars */
  header, .navbar, .hud-bar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.75rem !important;
  }

  .nav-controls, .header-actions {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
    justify-content: space-between !important;
  }

  /* Modal Mobile Sizing */
  .modal-dialog-scale {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    max-height: calc(100vh - 1.5rem) !important;
    max-height: calc(100dvh - 1.5rem) !important;
    border-radius: var(--radius-lg) !important;
  }
}

/* --------------------------------------------------------------------------
   9. PRINT & EXECUTIVE PDF EXPORT (@media print)
   -------------------------------------------------------------------------- */
@media print {
  @page {
    size: A4;
    margin: 12mm 15mm;
  }

  body {
    background: #ffffff !important;
    color: #0f172a !important;
    font-size: 11pt !important;
    line-height: 1.5 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .no-print, header, nav, .master-hud, .btn-logout-enterprise, button:not(.print-keep), #dante-fractal-bg {
    display: none !important;
  }

  .dante-card, .kpi-card, section {
    background: #ffffff !important;
    color: #0f172a !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: none !important;
    page-break-inside: avoid;
    margin-bottom: 1rem !important;
  }
}

/* --------------------------------------------------------------------------
   10. DANTE OS ENTERPRISE - BLINDAJE IP, ANTI-COPY & DRM (CAPA 1)
   -------------------------------------------------------------------------- */
.dante-secure-exam, body.exam-mode {
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none !important;
}

.dante-watermark-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 99999;
  opacity: 0.06;
  mix-blend-mode: overlay;
}

