/* ===== MODERN MOBILE ENHANCEMENTS ===== */

/* ===== LOADING STATES & SPINNERS ===== */

.spinner, .loader {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(53, 62, 161, 0.2);
  border-radius: 50%;
  border-top-color: #353ea1;
  animation: spin 0.8s linear infinite;
}

.spinner.small, .loader.small {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.spinner.large, .loader.large {
  width: 28px;
  height: 28px;
  border-width: 4px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Loading message */
.loading, .loading-message {
  display: flex;
  align-items: center;
  gap: 0.8em;
  padding: 1em;
  color: #666;
  font-size: 0.95em;
}

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  border-radius: 4px;
}

.skeleton.text {
  height: 1.2em;
  margin: 0.8em 0;
}

.skeleton.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-block;
}

.skeleton.button {
  height: 40px;
  min-width: 100px;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ===== MOBILE-OPTIMIZED INTERACTIVE ELEMENTS ===== */

/* Touch-friendly button sizing */
@media (max-width: 600px) {
  button, .btn, input[type="button"], input[type="submit"] {
    min-height: 44px;
    min-width: 44px;
    padding: 0.8em 1.2em;
    font-size: 1em;
  }

  a, .link {
    padding: 0.4em 0;
  }
}

/* Mobile-friendly links */
@media (max-width: 600px) {
  a, .link {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  nav a, nav .link {
    padding: 0.6em 0.8em;
  }
}

/* Increased tap target size */
@media (max-width: 600px) {
  button, a, input, textarea, select {
    outline-offset: -2px;
  }
}

/* ===== MOBILE SPACING & LAYOUT ===== */

@media (max-width: 600px) {
  body {
    line-height: 1.6;
  }

  h1 {
    font-size: 1.5rem;
    margin: 0.8em 0 0.4em 0;
  }

  h2 {
    font-size: 1.3rem;
    margin: 0.8em 0 0.3em 0;
  }

  h3 {
    font-size: 1.1rem;
  }

  p {
    margin: 1em 0;
  }

  ul, ol {
    margin: 1em 0;
    padding-left: 1.5em;
  }

  li {
    margin: 0.6em 0;
  }

  pre {
    margin: 1em 0;
    padding: 1em;
    font-size: 0.85em;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  code {
    font-size: 0.85em;
  }

  table {
    font-size: 0.9em;
  }

  th, td {
    padding: 0.6em 0.5em;
  }
}

/* ===== MOBILE NAVIGATION ===== */

@media (max-width: 600px) {
  nav, .navbar {
    padding: 0.5em 0;
  }

  nav a, nav .link {
    padding: 0.6em 0.8em;
    display: inline-block;
    margin: 0.2em 0;
  }

  nav ul, nav ol {
    margin: 0;
    padding: 0;
  }

  nav li {
    margin: 0;
  }

  /* Mobile menu toggle visibility */
  .menu-toggle, .hamburger {
    display: block !important;
    cursor: pointer;
  }
}

/* ===== MOBILE FORMS ===== */

@media (max-width: 600px) {
  input, textarea, select {
    font-size: 16px;
    padding: 0.8em;
    width: 100%;
    box-sizing: border-box;
    margin: 0.5em 0;
  }

  label {
    display: block;
    margin-bottom: 0.4em;
    font-weight: 500;
  }

  .form-group {
    margin: 1em 0;
  }

  button, input[type="button"], input[type="submit"] {
    width: 100%;
    padding: 0.8em;
  }
}

/* ===== MOBILE CONTAINERS & PADDING ===== */

@media (max-width: 600px) {
  .container {
    padding: 0 1em;
  }

  article, .article {
    padding: 1.5em 1em;
  }

  section {
    margin: 1.5em 0;
    padding: 1em;
  }
}

/* ===== MOBILE IMAGES & MEDIA ===== */

@media (max-width: 600px) {
  img, video, iframe {
    max-width: 100%;
    height: auto;
    display: block;
  }

  figure {
    margin: 1.5em 0;
  }

  figcaption {
    font-size: 0.9em;
    color: #666;
    margin-top: 0.5em;
  }
}

/* ===== MOBILE ALERTS & MODALS ===== */

@media (max-width: 600px) {
  .alert, .callout {
    padding: 0.75em;
    margin: 1em 0;
    font-size: 0.9em;
  }

  .modal, .dialog {
    width: 90vw;
    max-width: 300px;
    padding: 1.5em;
  }

  .modal-backdrop {
    backdrop-filter: blur(4px);
  }
}

/* ===== DARK THEME MOBILE ===== */

body.dark-theme .spinner, body.dark-theme .loader {
  border-color: rgba(122, 140, 255, 0.2);
  border-top-color: #7a8cff;
}

body.dark-theme .skeleton {
  background: linear-gradient(90deg, #3a3a50 25%, #4a4a60 50%, #3a3a50 75%);
}

body.dark-theme .loading, body.dark-theme .loading-message {
  color: #999;
}

/* ===== ACCESSIBILITY ===== */

/* Focus visible for keyboard navigation */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid #353ea1;
  outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }
}

/* High contrast mode support */
@media (prefers-contrast: more) {
  button, .btn {
    border-width: 2px;
  }

  a {
    text-decoration: underline;
  }
}

/* ===== SMALL SCREENS (< 480px) ===== */

@media (max-width: 480px) {
  html {
    font-size: 14px;
  }

  body {
    line-height: 1.5;
  }

  h1 {
    font-size: 1.3rem;
  }

  h2 {
    font-size: 1.1rem;
  }

  h3, h4, h5, h6 {
    font-size: 1rem;
  }

  .container {
    padding: 0 0.75em;
  }

  .spinner, .loader {
    width: 16px;
    height: 16px;
    border-width: 2px;
  }

  button, input[type="button"], input[type="submit"] {
    min-height: 40px;
    padding: 0.6em 1em;
    font-size: 0.95em;
  }

  pre {
    font-size: 0.8em;
    padding: 0.75em;
  }
}
