/* ===================================================================
   Modern CSS Reset and Normalize
   Based on modern reset principles and accessibility best practices
   =================================================================== */

/* ===== BOX SIZING ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* ===== DOCUMENT & ROOT ===== */
html {
  line-height: 1.15;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
  margin: 0;
  padding: 0;
  height: 100%;
  overflow-x: hidden;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* ===== BODY ===== */
body {
  margin: 0;
  padding: 0;
  font-family: var(--font-primary);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-normal);
  color: var(--text-color);
  background-color: var(--bg-white);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
}

/* ===== FOCUS MANAGEMENT ===== */
:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* ===== HEADINGS ===== */
h1, h2, h3, h4, h5, h6 {
  margin: 0 0 0.5em 0;
  font-family: var(--font-primary);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  color: var(--text-color);
}

h1 { font-size: var(--font-size-4xl); }
h2 { font-size: var(--font-size-3xl); }
h3 { font-size: var(--font-size-2xl); }
h4 { font-size: var(--font-size-xl); }
h5 { font-size: var(--font-size-lg); }
h6 { font-size: var(--font-size-base); }

/* ===== TEXT ELEMENTS ===== */
p {
  margin: 0 0 1em 0;
}

a {
  color: var(--primary-color);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover,
a:focus {
  color: var(--secondary-color);
  text-decoration: underline;
}

a:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

strong, b {
  font-weight: var(--font-weight-semibold);
}

em, i {
  font-style: italic;
}

small {
  font-size: var(--font-size-sm);
}

/* ===== LISTS ===== */
ul, ol {
  margin: 0 0 1em 0;
  padding-left: 1.5em;
}

li {
  margin-bottom: 0.25em;
}

ul ul,
ol ol,
ul ol,
ol ul {
  margin-bottom: 0;
}

/* ===== MEDIA ELEMENTS ===== */
img {
  max-width: 100%;
  height: auto;
  border: 0;
  border-radius: var(--radius-md);
}

svg {
  vertical-align: middle;
}

/* ===== FORM ELEMENTS ===== */
button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  margin: 0;
}

button,
input {
  overflow: visible;
}

button,
select {
  text-transform: none;
}

button,
[type="button"],
[type="reset"],
[type="submit"] {
  -webkit-appearance: button;
  cursor: pointer;
}

button:disabled,
[type="button"]:disabled,
[type="reset"]:disabled,
[type="submit"]:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
  border-style: none;
  padding: 0;
}

input,
textarea,
select {
  border: var(--input-border-width) solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--input-padding-y) var(--input-padding-x);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: var(--input-focus-shadow);
}

textarea {
  resize: vertical;
  min-height: 120px;
}

/* ===== TABLE ELEMENTS ===== */
table {
  border-collapse: collapse;
  border-spacing: 0;
  width: 100%;
}

th,
td {
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

th {
  font-weight: var(--font-weight-semibold);
  background-color: var(--bg-light);
}

/* ===== UTILITY RESETS ===== */
blockquote,
figure {
  margin: 0 0 1em 0;
}

hr {
  border: 0;
  border-top: 1px solid var(--border-color);
  margin: var(--space-xl) 0;
}

pre,
code {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
}

pre {
  background: var(--bg-light);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: 0 0 1em 0;
}

code {
  background: var(--bg-light);
  padding: 0.125em 0.25em;
  border-radius: var(--radius-sm);
}

pre code {
  background: none;
  padding: 0;
}

/* ===== MAIN ELEMENT ===== */
main {
  margin: 0;
  padding: 0;
  width: 100%;
}

/* ===== SECTION ELEMENTS ===== */
section {
  width: 100%;
}

/* ===== HIDDEN ELEMENTS ===== */
[hidden] {
  display: none !important;
}

.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;
}

/* ===== PRINT STYLES ===== */
@media print {
  *,
  *::before,
  *::after {
    background: transparent !important;
    color: black !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }
  
  a,
  a:visited {
    text-decoration: underline;
  }
  
  img {
    page-break-inside: avoid;
  }
  
  h2,
  h3,
  p {
    orphans: 3;
    widows: 3;
  }
  
  h2,
  h3 {
    page-break-after: avoid;
  }
}

/* ===== MOBILE OVERFLOW PREVENTION ===== */
@media (max-width: 768px) {
  html,
  body {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  
  .container,
  .container-fluid,
  .container-sm,
  .container-md,
  .container-lg,
  .container-xl {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 15px !important;
    padding-right: 15px !important;
  }
  
  .row {
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  
  [class*="col-"]:not(.modern-footer [class*="col-"]) {
    padding-left: 15px !important;
    padding-right: 15px !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  
  /* Footer columns should maintain their responsive behavior */
  .modern-footer [class*="col-"] {
    padding-left: 15px !important;
    padding-right: 15px !important;
  }
  
  /* Navbar specific fixes */
  .navbar,
  .modern-navbar {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
  }
  
  .navbar-collapse {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
  }
  
  /* Prevent all wide elements from causing horizontal scroll */
  * {
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  
  /* Exception for small elements that should maintain their size */
  i,
  span:not(.navbar-toggler-icon),
  button:not(.navbar-toggler),
  img[width="40"],
  img[width="50"],
  img[height="40"],
  img[height="50"] {
    max-width: none !important;
  }
}