/* Global focus removal */
*:focus {
  outline: none !important;
}

/* Smooth focus for inputs only */
input:not([type="button"]):not([type="submit"]):not([type="reset"]):not(
    [type="checkbox"]
  ):not([type="radio"]):focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--y-main, #ac5300) !important;
  box-shadow: 0 0 8px rgba(172, 83, 0, 0.2) !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  background-color: #ffefe2;
  font-family: var(--y-font-family);
}

main {
  flex: 1 0 auto;
  width: 100%;
  padding: 0;
}

footer {
  flex-shrink: 0;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0;
  font-weight: var(--y-font-weight-bold);
  line-height: var(--y-line-height-heading);
}

p {
  margin: 0;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
optgroup,
select,
textarea {
  font-family: inherit;
  font-size: 100%;
  line-height: 1.15;
  margin: 0;
}

button,
input {
  overflow: visible;
}

button,
select {
  text-transform: none;
}

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

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

fieldset {
  padding: 0.35em 0.75em 0.625em;
}

legend {
  box-sizing: border-box;
  color: inherit;
  display: table;
  max-width: 100%;
  padding: 0;
  white-space: normal;
}

progress {
  vertical-align: baseline;
}

textarea {
  overflow: auto;
}

[type="checkbox"],
[type="radio"] {
  box-sizing: border-box;
  padding: 0;
}

[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
  height: auto;
}

[type="search"] {
  -webkit-appearance: textfield;
  outline-offset: -2px;
}

[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
}

::-webkit-file-upload-button {
  -webkit-appearance: button;
  font: inherit;
}

details {
  display: block;
}

summary {
  display: list-item;
}

template {
  display: none;
}

[hidden] {
  display: none;
}

/* ========== Global Responsive Fixes ========== */

/* RTL Scrollbar - Left side for Arabic (browsers handle this differently, but we can force direction) */
html {
  direction: rtl;
}

/* For Webkit browsers (Chrome, Safari) */
::-webkit-scrollbar {
  width: 10px;
  background-color: #f1f1f1;
}

::-webkit-scrollbar-track {
  background-color: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background-color: #888;
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background-color: #555;
}

/* For Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: #888 #f1f1f1;
}

/* Prevent horizontal overflow */
html,
body {
  overflow-x: hidden;
  max-width: 100vw;
}

/* Ensure all containers respect viewport */
* {
  max-width: 100%;
}

/* Responsive images */
img {
  height: auto;
  max-width: 100%;
  object-fit: contain;
}

/* Responsive tables */
table {
  width: 100%;
  border-collapse: collapse;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Responsive containers */
.container,
.container-fluid {
  width: 100%;
  padding-left: 1rem;
  padding-right: 1rem;
  margin-left: auto;
  margin-right: auto;
}

/* Responsive text */
h1,
h2,
h3,
h4,
h5,
h6 {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

p,
span,
a,
li {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Responsive buttons */
button,
.btn,
a.btn {
  white-space: nowrap;
  min-width: fit-content;
}

/* Mobile-first responsive breakpoints */
@media (max-width: 576px) {
  /* Extra small devices */
  html {
    font-size: 14px;
  }

  .container {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  h1 {
    font-size: clamp(1.5rem, 8vw, 3rem);
  }
  h2 {
    font-size: clamp(1.25rem, 7vw, 2.5rem);
  }
  h3 {
    font-size: clamp(1.1rem, 6vw, 2rem);
  }
  h4 {
    font-size: clamp(1rem, 5vw, 1.75rem);
  }
  h5 {
    font-size: clamp(0.9rem, 4.5vw, 1.5rem);
  }
  h6 {
    font-size: clamp(0.85rem, 4vw, 1.25rem);
  }
}

@media (min-width: 577px) and (max-width: 768px) {
  /* Small devices */
  html {
    font-size: 16px;
  }
}

@media (min-width: 769px) and (max-width: 992px) {
  /* Medium devices */
  html {
    font-size: 16px;
  }
}

@media (min-width: 993px) {
  /* Large devices */
  html {
    font-size: 16px;
  }

  .container {
    max-width: 1200px;
  }
}

/* Common responsive fixes for all screen sizes */
@media (max-width: 992px) {
  /* Reduce padding on medium and smaller screens */
  section,
  .section {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  /* Stack flex containers */
  .flex-row {
    flex-direction: column;
  }

  /* Full width on smaller screens */
  .col-md-6,
  .col-md-4,
  .col-md-3 {
    width: 100%;
    max-width: 100%;
  }
}

@media (max-width: 768px) {
  /* Mobile optimizations */
  body {
    font-size: 1rem;
  }

  /* Reduce gaps and spacing */
  .gap-3,
  .gap-4,
  .gap-5 {
    gap: 1rem !important;
  }

  /* Stack grid items (but exclude navbar) */
  [class*="grid"]:not(.navbar) {
    grid-template-columns: 1fr !important;
  }

  /* Full width buttons on mobile */
  button,
  .btn,
  a.btn {
    width: 100%;
    max-width: 100%;
  }

  /* Reduce padding */
  .p-4,
  .p-5,
  .px-4,
  .px-5 {
    padding: 1rem !important;
  }

  /* Center align text on mobile */
  .text-start {
    text-align: center !important;
  }
}

/* Fix for fixed width elements */
@media (max-width: 576px) {
  *[style*="width"]:not([style*="max-width"]):not([style*="min-width"]) {
    max-width: 100% !important;
  }

  /* Ensure no element exceeds viewport */
  div,
  section,
  article,
  aside,
  header,
  footer,
  main {
    max-width: 100vw;
  }
}
