/* ======= ENTERPRISE-GRADE RESET + NORMALIZE CSS FOUNDATION ======= */
/* Author: Inspired by award-winning systems (Tom-style | Saeed’s version) */

/* ==== DESIGN TOKENS & ROOT LEVEL ==== */
:root {
  --font-base: 'Inter', system-ui, sans-serif;
  --font-code: 'Fira Code', monospace;
  --text-size: 16px;
  --line-height-base: 1.6;

  --radius-sm: 4px;
  --radius-md: 8px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
  --transition-fast: 150ms ease-in-out;
  --transition-default: 0.2s ease-in-out;

  --color-bg: #ffffff;
  --color-fg: #1f2937;
  --color-muted: #6b7280;
  --color-primary: #2563eb;
  --color-border: #e5e7eb;
  --color-selection: #dbeafe;
  --focus-ring: 2px dashed var(--color-primary);
}

/* ==== GLOBAL RESET ==== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  min-width: 0;
}
html, body {
  height: 100%;
  font-family: var(--font-base);
  font-size: var(--text-size);
  line-height: var(--line-height-base);
  background: var(--color-bg);
  color: var(--color-fg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

/* ==== HEADINGS & TEXT ==== */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.25;
}
p {
  margin-bottom: 1rem;
}
strong, b {
  font-weight: bolder;
}
em {
  font-style: italic;
}
a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition-default);
}
a:hover, a:focus-visible {
  text-decoration: underline;
}

/* ==== SELECTION ==== */
::selection {
  background-color: var(--color-selection);
  color: #000;
}

/* ==== MEDIA ELEMENTS ==== */
img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
  height: auto;
}
iframe {
  border: none;
  width: 100%;
}

/* ==== FORM ELEMENTS ==== */
input, select, textarea, button {
  font: inherit;
  color: inherit;
  background-color: transparent;
  border: 1px solid var(--color-border);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  transition: border-color var(--transition-default), background-color var(--transition-default);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}
button {
  cursor: pointer;
  background-color: var(--color-primary);
  color: white;
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-fast);
}
button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ==== TABLES ==== */
table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
th, td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--color-border);
}

/* ==== LISTS ==== */
ul, ol {
  list-style: none;
  padding-left: 1.25rem;
}

/* ==== CODE ==== */
pre, code, kbd, samp {
  font-family: var(--font-code);
  background: #f9f9f9;
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-size: 0.875em;
}

/* ==== ACCESSIBILITY ==== */
:focus {
  outline: var(--focus-ring);
  outline-offset: 3px;
}
:focus:not(:focus-visible) {
  outline: none;
}
:focus-visible {
  outline: var(--focus-ring);
}
[hidden] {
  display: none !important;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ==== HTML5 STRUCTURE ==== */
details {
  border: 1px solid var(--color-border);
  padding: 1rem;
  border-radius: var(--radius-md);
}
summary {
  cursor: pointer;
  font-weight: 600;
}
dialog {
  border: none;
  border-radius: var(--radius-md);
  padding: 2rem;
  background: var(--color-bg);
  box-shadow: var(--shadow-sm);
}

/* ==== SCROLLBAR ==== */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover {
  background-color: rgba(0, 0, 0, 0.4);
}

/* ==== DARK MODE ==== */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0d1117;
    --color-fg: #f5f5f5;
    --color-muted: #9ca3af;
    --color-border: #30363d;
    --color-selection: #2563eb;
  }
}

/* ==== RTL SUPPORT ==== */
html[dir="rtl"] {
  direction: rtl;
}
html[dir="rtl"] body {
  text-align: right;
}

/* ==== PRINT OPTIMIZATION ==== */
@media print {
  *, *::before, *::after {
    background: none !important;
    color: black !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }
  a, a:visited {
    text-decoration: underline;
  }
  abbr[title]::after {
    content: " (" attr(title) ")";
  }
  pre, blockquote {
    page-break-inside: avoid;
  }
  thead {
    display: table-header-group;
  }
  tr, img {
    page-break-inside: avoid;
  }
}
