/* ════════════════════════════════════════════════════════════════════════════════
   FITTRACK RESPONSIVE DESIGN SYSTEM
   Mobile-first approach for all screen sizes
   ════════════════════════════════════════════════════════════════════════════════ */

/* ════════════════════ GLOBAL RESPONSIVE TYPOGRAPHY ════════════════════ */
h1 {
  font-size: clamp(28px, 5vw, 48px);
  line-height: 1.2;
}

h2 {
  font-size: clamp(22px, 4vw, 36px);
  line-height: 1.3;
}

h3 {
  font-size: clamp(18px, 3vw, 28px);
  line-height: 1.4;
}

h4 {
  font-size: clamp(16px, 2.5vw, 24px);
  line-height: 1.4;
}

h5, h6 {
  font-size: clamp(14px, 2vw, 20px);
  line-height: 1.5;
}

p {
  font-size: 16px;
  line-height: 1.6;
}

@media (max-width: 640px) {
  p {
    font-size: 15px;
  }
}

/* ════════════════════ IMAGES RESPONSIVE ════════════════════ */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

picture {
  display: block;
  width: 100%;
}

/* ════════════════════ CONTAINERS & LAYOUT ════════════════════ */
.container,
.max-w-6xl,
.max-w-5xl,
.max-w-4xl,
.max-w-3xl,
.max-w-2xl {
  width: 100%;
  max-width: 100%;
  padding-left: 1rem;
  padding-right: 1rem;
  margin-left: auto;
  margin-right: auto;
}

.max-w-6xl {
  max-width: 1280px;
}

.max-w-5xl {
  max-width: 1024px;
}

.max-w-4xl {
  max-width: 896px;
}

.max-w-3xl {
  max-width: 768px;
}

.max-w-2xl {
  max-width: 640px;
}

@media (min-width: 640px) {
  .container,
  .max-w-6xl,
  .max-w-5xl,
  .max-w-4xl,
  .max-w-3xl,
  .max-w-2xl {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
}

@media (min-width: 1024px) {
  .container,
  .max-w-6xl,
  .max-w-5xl,
  .max-w-4xl,
  .max-w-3xl,
  .max-w-2xl {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

/* ════════════════════ SECTION SPACING ════════════════════ */
section {
  padding: 40px 1rem;
}

@media (min-width: 640px) {
  section {
    padding: 50px 1.5rem;
  }
}

@media (min-width: 768px) {
  section {
    padding: 60px 1.5rem;
  }
}

@media (min-width: 1024px) {
  section {
    padding: 80px 2rem;
  }
}

/* ════════════════════ FLEXBOX RESPONSIVE ════════════════════ */
.flex-col-mobile {
  display: flex;
  flex-direction: column;
}

@media (min-width: 768px) {
  .flex-col-mobile {
    flex-direction: row;
  }
}

/* ════════════════════ GRID RESPONSIVE ════════════════════ */
.grid-cols-auto {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 640px) {
  .grid-cols-auto {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }
}

@media (min-width: 1024px) {
  .grid-cols-auto {
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
  }
}

/* Override Tailwind Grid Classes for Mobile */
.grid {
  width: 100%;
  gap: 1rem;
}

.grid.grid-cols-2 {
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .grid.grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
  }
}

.grid.grid-cols-3 {
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .grid.grid-cols-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .grid.grid-cols-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

.grid.grid-cols-4 {
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .grid.grid-cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .grid.grid-cols-4 {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ════════════════════ CARD RESPONSIVE ════════════════════ */
.card {
  width: 100%;
  padding: 1.5rem;
}

@media (min-width: 768px) {
  .card {
    padding: 2rem;
  }
}

/* ════════════════════ NAVBAR MOBILE RESPONSIVE ════════════════════ */
nav {
  width: 100%;
  overflow-x: hidden;
}

.navbar-sticky {
  position: sticky;
  top: 0;
  z-index: 50;
  width: 100%;
}

/* Mobile Menu Styles */
.mobile-menu {
  display: none;
  width: 100%;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border-bottom: 1px solid #e5e7eb;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-in-out;
}

.mobile-menu.active {
  display: block;
  max-height: 500px;
}

.mobile-menu a {
  display: block;
  padding: 1rem;
  color: #1f2937;
  text-decoration: none;
  border-bottom: 1px solid #f3f4f6;
  width: 100%;
  text-align: left;
  transition: background-color 0.2s ease;
}

.mobile-menu a:hover {
  background-color: #f9fafb;
  color: #16a34a;
}

.mobile-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.mobile-menu-btn svg {
  width: 24px;
  height: 24px;
  stroke: #1f2937;
  transition: transform 0.3s ease;
}

@media (min-width: 768px) {
  .mobile-menu {
    display: none !important;
  }

  .mobile-menu-btn {
    display: none !important;
  }

  .nav-links {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }
}

/* ════════════════════ BUTTON RESPONSIVE ════════════════════ */
button,
.btn,
a.btn {
  padding: 0.75rem 1.5rem;
  min-height: 44px;
  font-size: 16px;
  width: 100%;
  max-width: 100%;
}

@media (min-width: 640px) {
  button,
  .btn,
  a.btn {
    width: auto;
    max-width: 100%;
  }
}

.btn-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

@media (min-width: 640px) {
  .btn-group {
    flex-direction: row;
    gap: 0.5rem;
    width: auto;
  }
}

/* ════════════════════ FORM RESPONSIVE ════════════════════ */
form {
  width: 100%;
}

input,
select,
textarea {
  width: 100%;
  font-size: 16px;
  padding: 0.75rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  box-sizing: border-box;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #16a34a;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1);
}

.form-group {
  margin-bottom: 1.5rem;
  width: 100%;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  width: 100%;
}

@media (min-width: 640px) {
  .form-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }
}

/* ════════════════════ TABLE RESPONSIVE ════════════════════ */
.table-container {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 0.5rem;
}

table {
  width: 100%;
  min-width: 300px;
  border-collapse: collapse;
}

thead th {
  padding: 1rem;
  text-align: left;
  font-weight: 600;
  background-color: #f9fafb;
  border-bottom: 2px solid #e5e7eb;
  font-size: 14px;
}

tbody td {
  padding: 1rem;
  border-bottom: 1px solid #f3f4f6;
  font-size: 14px;
}

@media (min-width: 640px) {
  thead th,
  tbody td {
    padding: 1.25rem;
    font-size: 15px;
  }
}

@media (min-width: 1024px) {
  thead th,
  tbody td {
    padding: 1.5rem;
    font-size: 16px;
  }
}

/* ════════════════════ HERO SECTION RESPONSIVE ════════════════════ */
.hero-section {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

@media (min-width: 768px) {
  .hero-section {
    padding: 4rem 2rem;
  }
}

.hero-content {
  width: 100%;
  max-width: 100%;
  text-align: center;
}

@media (min-width: 768px) {
  .hero-content {
    max-width: 600px;
  }
}

/* ════════════════════ MODAL/DROPDOWN RESPONSIVE ════════════════════ */
.dropdown-menu,
.modal-menu,
.submenu {
  width: 100vw;
  max-width: 100%;
  position: fixed;
  left: 0;
  right: 0;
}

@media (min-width: 768px) {
  .dropdown-menu,
  .modal-menu,
  .submenu {
    width: auto;
    max-width: 400px;
    position: absolute;
  }
}

/* ════════════════════ AVATAR & PROFILE RESPONSIVE ════════════════════ */
.avatar {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
}

@media (min-width: 768px) {
  .avatar {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
  }
}

/* ════════════════════ SPACING UTILITIES MOBILE ════════════════════ */
@media (max-width: 768px) {
  /* Reduce top/bottom padding on mobile */
  .py-20 { padding-top: 2rem; padding-bottom: 2rem; }
  .py-24 { padding-top: 2.5rem; padding-bottom: 2.5rem; }
  .py-32 { padding-top: 3rem; padding-bottom: 3rem; }
  
  /* Reduce horizontal gaps on mobile */
  .gap-12 { gap: 1.5rem; }
  .gap-8 { gap: 1rem; }
  .gap-6 { gap: 0.75rem; }
  
  /* Reduce padding on cards */
  .p-12 { padding: 1.5rem; }
  .p-8 { padding: 1rem; }
  .px-8 { padding-left: 1rem; padding-right: 1rem; }
}

/* ════════════════════ HIDE/SHOW UTILITIES ════════════════════ */
@media (max-width: 768px) {
  .hidden-mobile {
    display: none !important;
  }

  .shown-mobile {
    display: block;
  }
}

@media (min-width: 769px) {
  .shown-mobile {
    display: none !important;
  }

  .hidden-mobile {
    display: block;
  }
}

/* ════════════════════ ACCESSIBILITY ════════════════════ */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ════════════════════ TOUCH DEVICE OPTIMIZATIONS ════════════════════ */
@media (hover: none) {
  button:hover,
  a:hover {
    /* Remove hover effects on touch devices */
    background-color: inherit;
    color: inherit;
  }

  /* Make touch targets larger */
  button,
  a[role="button"],
  input[type="button"],
  input[type="submit"] {
    min-height: 48px;
    min-width: 48px;
  }
}

/* ════════════════════ PRINT STYLES ════════════════════ */
@media print {
  body {
    background: white;
    color: black;
  }

  a {
    text-decoration: underline;
  }

  .no-print {
    display: none;
  }

  section {
    page-break-inside: avoid;
    padding: 1rem 0;
  }
}

/* ════════════════════ VIEWPORT SAFEGUARDS ════════════════════ */
html,
body {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* {
  box-sizing: border-box;
  max-width: 100%;
}

/* Prevent horizontal scrolling */
body,
html {
  min-width: 100%;
}

/* ════════════════════ LANDSCAPE MODE OPTIMIZATIONS ════════════════════ */
@media (max-height: 600px) and (orientation: landscape) {
  section {
    padding: 20px 1rem;
  }

  h1, h2, h3 {
    margin: 0.5rem 0;
  }

  .mobile-menu {
    max-height: 400px;
    overflow-y: auto;
  }
}
