/* ============================================================================
   ITVedas — Enterprise Knowledge Platform Shared Stylesheet
   Modern, High-Performance, Mobile-First Design System (WCAG 2.1 AA Compliant)
   ============================================================================ */

/* ── Design Tokens ────────────────────────────────────────────────────────── */
:root {
  color-scheme: light;

  /* Surfaces & Backgrounds */
  --bg:            #EEF3FC; /* Light ice-blue canvas */
  --bg2:           #FFFFFF; /* Surface white */
  --bg3:           #F8FAFD; /* Tinted container */
  --card:          #FFFFFF; /* Crisp card background */
  --card-hover:    #FFFFFF;

  /* Text & Contrast (Strictly WCAG 2.1 AA Compliant) */
  --text:          #0F172A; /* Slate 900 — 14.5:1 on white */
  --text-primary:  #0F172A;
  --text-secondary:#334155; /* Slate 700 — 8.2:1 on white */
  --muted:         #475569; /* Slate 600 — 5.2:1 on white (AA pass for body) */
  --sub:           #334155;
  --border:        rgba(15, 23, 42, 0.12);
  --border-subtle: rgba(15, 23, 42, 0.08);

  /* Primary Brand Tokens */
  --brand-navy:    #0B2750;
  --brand-orange:  #FF7A00;
  --accent:        #FF7A00;
  --accent-hover:  #E06900;
  --accent-glow:   rgba(255, 122, 0, 0.18);

  /* Technical Category Accents */
  --net:           #FF6B35; /* Networking */
  --cld:           #2563EB; /* Cloud */
  --sec:           #059669; /* Security */
  --dev:           #7C3AED; /* DevOps */
  --db:            #D97706; /* Databases */
  --os:            #DC2626; /* Linux & OS */
  --hw:            #0891B2; /* Hardware */
  --comp:          #DB2777; /* Compliance */
  --news:          #0D9488; /* Tech News */
  --ai:            #6366F1; /* AI & Models */

  /* Typography */
  --fd:            'Lexend', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --fb:            'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --fl:            'Lexend', sans-serif;
  --font-mono:     ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Spacing Scale */
  --spacing-2xs:   0.125rem;
  --spacing-xs:    0.25rem;
  --spacing-sm:    0.5rem;
  --spacing-md:    1rem;
  --spacing-lg:    1.5rem;
  --spacing-xl:    2rem;
  --spacing-2xl:   3rem;
  --spacing-3xl:   4.5rem;

  /* Border Radii */
  --radius-xs:     4px;
  --radius-sm:     6px;
  --radius-md:     10px;
  --radius-lg:     14px;
  --radius-xl:     20px;
  --radius-full:   9999px;

  /* Shadows & Elevation */
  --shadow-sm:     0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-md:     0 4px 14px rgba(15, 23, 42, 0.07);
  --shadow-lg:     0 12px 30px rgba(15, 23, 42, 0.09);
  --shadow-hover:  0 14px 34px rgba(11, 39, 80, 0.12);

  /* Transitions */
  --transition-fast:   150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 220ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow:   320ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Layout & Viewports */
  --header-height: 64px;
  --max-width:     1200px;
  --content-width: 860px;
  --prose-width:   72ch;
}

/* ── Global Reset ─────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 1.5rem);
  background-color: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--fb);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1 0 auto;
}

/* ── Typography ───────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--fd);
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.25;
  margin-bottom: var(--spacing-md);
}

h1 { font-size: clamp(2rem, 4.5vw, 3.25rem); line-height: 1.15; }
h2 { font-size: clamp(1.5rem, 3.2vw, 2.25rem); line-height: 1.25; margin-top: 2.5rem; }
h3 { font-size: clamp(1.2rem, 2.4vw, 1.65rem); line-height: 1.35; margin-top: 1.75rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.1rem; }
h6 { font-size: 0.95rem; }

p {
  color: var(--text-secondary);
  margin-bottom: var(--spacing-md);
  font-size: 1.025rem;
  line-height: 1.75;
}

p.lead {
  font-size: clamp(1.1rem, 2vw, 1.25rem);
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: var(--spacing-xl);
}

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

a:hover {
  color: var(--accent);
}

strong, b {
  font-weight: 600;
  color: var(--text);
}

code {
  background: rgba(15, 23, 42, 0.05);
  border: 1px solid var(--border);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: var(--brand-navy);
}

pre {
  background: #0B192C;
  color: #E2E8F0;
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: var(--spacing-lg) 0;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  line-height: 1.6;
  border: 1px solid rgba(255,255,255,0.08);
}

pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
}

/* ── Accessible Focus & Skip Link ─────────────────────────────────────────── */
:focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius-xs);
}

.skip-link {
  position: absolute;
  top: -60px;
  left: 1rem;
  background: var(--brand-navy);
  color: #FFFFFF;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  z-index: 1000;
  transition: top var(--transition-fast);
  box-shadow: var(--shadow-lg);
}

.skip-link:focus {
  top: 1rem;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ── Containers & Layout ─────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--spacing-lg);
}

.container-narrow {
  width: 100%;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 var(--spacing-lg);
}

.grid {
  display: grid;
  gap: var(--spacing-lg);
}

.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.gap-xs { gap: var(--spacing-xs); }
.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }
.flex-wrap { flex-wrap: wrap; }

/* ── Buttons & Interactive Controls (Min 44px Touch Target) ───────────────── */
button, input, select, textarea {
  font-family: inherit;
  font-size: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius-md);
  font-family: var(--fd);
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-normal);
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--brand-orange);
  color: #FFFFFF;
  border-color: var(--brand-orange);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #FFFFFF;
}

.btn-secondary {
  background: var(--bg2);
  color: var(--brand-navy);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--bg3);
  border-color: var(--brand-navy);
  color: var(--brand-navy);
}

.btn-navy {
  background: var(--brand-navy);
  color: #FFFFFF;
}

.btn-navy:hover {
  background: #143566;
  color: #FFFFFF;
}

.btn-sm {
  min-height: 38px;
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  min-height: 52px;
  padding: 0.85rem 2rem;
  font-size: 1.05rem;
  border-radius: var(--radius-lg);
}

/* ── Modern Cards & Surfaces ──────────────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  transition: all var(--transition-normal);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.card:hover {
  border-color: rgba(255, 122, 0, 0.4);
  box-shadow: var(--shadow-hover);
  transform: translateY(-3px);
}

.card-clickable {
  cursor: pointer;
}

.surface {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* ── Badges & Tags ────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 28px;
  padding: 0.2rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg3);
  color: var(--muted);
  border: 1px solid var(--border);
}

.badge-net  { background: rgba(255,107,53,0.1);  color: var(--net);  border-color: rgba(255,107,53,0.3); }
.badge-cld  { background: rgba(37,99,235,0.1);   color: var(--cld);  border-color: rgba(37,99,235,0.3); }
.badge-sec  { background: rgba(5,150,105,0.1);   color: var(--sec);  border-color: rgba(5,150,105,0.3); }
.badge-dev  { background: rgba(124,58,237,0.1);  color: var(--dev);  border-color: rgba(124,58,237,0.3); }
.badge-db   { background: rgba(217,119,6,0.1);   color: var(--db);   border-color: rgba(217,119,6,0.3); }
.badge-os   { background: rgba(220,38,38,0.1);   color: var(--os);   border-color: rgba(220,38,38,0.3); }
.badge-hw   { background: rgba(8,145,178,0.1);   color: var(--hw);   border-color: rgba(8,145,178,0.3); }
.badge-comp { background: rgba(219,39,119,0.1);  color: var(--comp); border-color: rgba(219,39,119,0.3); }
.badge-ai   { background: rgba(99,102,241,0.1);  color: var(--ai);   border-color: rgba(99,102,241,0.3); }

/* CVE Severity Badges */
.badge-critical { background: #FEE2E2; color: #991B1B; border-color: #F87171; font-weight: 700; }
.badge-high     { background: #FFEDD5; color: #9A3412; border-color: #FB923C; font-weight: 700; }
.badge-medium   { background: #FEF3C7; color: #92400E; border-color: #FCD34D; font-weight: 600; }
.badge-low      { background: #ECFDF5; color: #065F46; border-color: #6EE7B7; font-weight: 600; }

/* ── Forms & Inputs ───────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: var(--spacing-md);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  min-height: 46px;
  padding: 0.65rem 1rem;
  background: var(--bg2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 1rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  outline: none;
}

.form-input::placeholder {
  color: #94A3B8;
}

/* ── Responsive Tables & Data Grids ───────────────────────────────────────── */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: var(--spacing-lg) 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg2);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th {
  background: var(--bg3);
  color: var(--brand-navy);
  font-family: var(--fd);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.85rem 1.25rem;
  border-bottom: 2px solid var(--border);
}

td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.925rem;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover td {
  background: rgba(11, 39, 80, 0.02);
}

/* ── Mobile Table Card Transformation (< 768px) ───────────────────────────── */
@media (max-width: 768px) {
  .table-cards-mobile thead {
    display: none;
  }

  .table-cards-mobile, 
  .table-cards-mobile tbody, 
  .table-cards-mobile tr, 
  .table-cards-mobile td {
    display: block;
    width: 100%;
  }

  .table-cards-mobile tr {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-md);
    box-shadow: var(--shadow-sm);
  }

  .table-cards-mobile td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-subtle);
  }

  .table-cards-mobile td:last-child {
    border-bottom: none;
  }

  .table-cards-mobile td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--brand-navy);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-right: 1rem;
  }
}

/* ── Breakpoint Refinements ───────────────────────────────────────────────── */
@media (max-width: 1024px) {
  :root {
    --max-width: 960px;
  }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
  :root {
    --header-height: 58px;
    --spacing-lg: 1.15rem;
    --spacing-xl: 1.5rem;
    --spacing-2xl: 2rem;
  }

  body {
    font-size: 15px;
  }

  .container, .container-narrow {
    padding: 0 1.15rem;
  }

  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }

  .flex-col-mobile {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }

  .card {
    padding: 1.25rem;
  }
}

/* ── Accessibility: 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;
  }
}
