/* ===========================================
   Responsive Design Utilities - Concerota
   Standard breakpoints and shared responsive patterns
   =========================================== */

/* ===========================================
   CSS Custom Properties for Breakpoints
   =========================================== */
:root {
  /* Standard breakpoint values (for reference in JS if needed) */
  --bp-phone: 480px;
  --bp-tablet: 768px;
  --bp-desktop: 1024px;
  --bp-wide: 1280px;
}

/* ===========================================
   Mobile Table Utilities
   Horizontal scroll with sticky first column
   =========================================== */
.responsive-table-container {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--rose-medium, #c9899e) transparent;
}

.responsive-table-container::-webkit-scrollbar {
  height: 8px;
}

.responsive-table-container::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 4px;
}

.responsive-table-container::-webkit-scrollbar-thumb {
  background: var(--rose-medium, #c9899e);
  border-radius: 4px;
}

.responsive-table-container::-webkit-scrollbar-thumb:hover {
  background: var(--rose-rich, #a85a72);
}

/* Sticky first column for tables */
.sticky-first-col th:first-child,
.sticky-first-col td:first-child {
  position: sticky;
  left: 0;
  z-index: 10;
  background: inherit;
}

/* Ensure sticky column has shadow to indicate scroll */
.sticky-first-col th:first-child::after,
.sticky-first-col td:first-child::after {
  content: '';
  position: absolute;
  top: 0;
  right: -8px;
  bottom: 0;
  width: 8px;
  background: linear-gradient(to right, rgba(0,0,0,0.08), transparent);
  pointer-events: none;
}

/* ===========================================
   Touch-Friendly Utilities
   =========================================== */
@media (max-width: 767px) {
  /* Minimum touch target size */
  .touch-target,
  button,
  .btn,
  [role="button"],
  input[type="submit"],
  input[type="button"] {
    min-height: 44px;
    min-width: 44px;
  }

  /* Larger tap areas for links in lists */
  .touch-list a,
  .touch-list button {
    display: block;
    padding: 12px 16px;
  }
}

/* ===========================================
   Responsive Grid Utilities
   =========================================== */
.responsive-grid {
  display: grid;
  gap: 20px;
}

/* 4 columns on wide, 3 on desktop, 2 on tablet, 1 on mobile */
.responsive-grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

.responsive-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.responsive-grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 1279px) {
  .responsive-grid-4 {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 1023px) {
  .responsive-grid-4,
  .responsive-grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 767px) {
  .responsive-grid-4,
  .responsive-grid-3,
  .responsive-grid-2 {
    grid-template-columns: 1fr;
  }
}

/* ===========================================
   Responsive Flexbox Utilities
   =========================================== */
.responsive-flex {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

/* Stack vertically on mobile */
@media (max-width: 767px) {
  .responsive-flex-stack {
    flex-direction: column;
  }

  .responsive-flex-stack > * {
    width: 100%;
  }
}

/* ===========================================
   Prevent iOS Safari Auto-Zoom on Focus
   Text-entry controls below 16px make iOS zoom the page on focus.
   Force >=16px on phones. (Page inline styles load after this file, so
   !important is required to win the cascade.)
   =========================================== */
@media (max-width: 480px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="hidden"]),
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* ===========================================
   Responsive Form Utilities
   =========================================== */
.responsive-form-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

@media (max-width: 767px) {
  .responsive-form-row {
    flex-direction: column;
    gap: 12px;
  }

  .responsive-form-row > * {
    width: 100%;
  }

  .responsive-form-row input,
  .responsive-form-row select,
  .responsive-form-row textarea {
    width: 100%;
    box-sizing: border-box;
  }
}

/* ===========================================
   Responsive Typography
   =========================================== */
.responsive-heading {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  line-height: 1.2;
}

.responsive-subheading {
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  line-height: 1.3;
}

.responsive-text {
  font-size: clamp(0.875rem, 2vw, 1rem);
  line-height: 1.5;
}

/* ===========================================
   Collapsible Sections for Mobile
   =========================================== */
.collapsible-section {
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  margin-bottom: 12px;
  overflow: hidden;
}

.collapsible-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.02);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.collapsible-header:hover {
  background: rgba(0, 0, 0, 0.04);
}

.collapsible-icon {
  transition: transform 0.3s ease;
  font-size: 1.2em;
}

.collapsible-section.collapsed .collapsible-icon {
  transform: rotate(-90deg);
}

.collapsible-content {
  padding: 16px;
  transition: max-height 0.3s ease, padding 0.3s ease;
  overflow: hidden;
}

.collapsible-section.collapsed .collapsible-content {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
}

/* Only collapse on mobile */
@media (min-width: 768px) {
  .collapsible-section.mobile-only {
    border: none;
    border-radius: 0;
  }

  .collapsible-section.mobile-only .collapsible-header {
    display: none;
  }

  .collapsible-section.mobile-only .collapsible-content {
    max-height: none !important;
    padding: 0;
  }

  .collapsible-section.mobile-only.collapsed .collapsible-content {
    max-height: none !important;
  }
}

/* ===========================================
   Responsive Spacing Utilities
   =========================================== */
.responsive-padding {
  padding: 40px;
}

.responsive-margin {
  margin: 40px;
}

@media (max-width: 1023px) {
  .responsive-padding {
    padding: 30px;
  }
  .responsive-margin {
    margin: 30px;
  }
}

@media (max-width: 767px) {
  .responsive-padding {
    padding: 16px;
  }
  .responsive-margin {
    margin: 16px;
  }
}

/* ===========================================
   Hide/Show at Breakpoints
   =========================================== */
/* Hide on mobile (below 768px) */
@media (max-width: 767px) {
  .hide-mobile {
    display: none !important;
  }
}

/* Hide on tablet and below (below 1024px) */
@media (max-width: 1023px) {
  .hide-tablet {
    display: none !important;
  }
}

/* Hide on desktop (768px and above) */
@media (min-width: 768px) {
  .show-mobile-only {
    display: none !important;
  }
}

/* Hide on large desktop (1024px and above) */
@media (min-width: 1024px) {
  .show-tablet-only {
    display: none !important;
  }
}

/* ===========================================
   Responsive Container
   =========================================== */
.responsive-container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 40px;
  box-sizing: border-box;
}

@media (max-width: 1023px) {
  .responsive-container {
    padding: 0 24px;
  }
}

@media (max-width: 767px) {
  .responsive-container {
    padding: 0 16px;
  }
}

/* ===========================================
   Horizontal Scroll Indicator
   Shows gradient hint that content is scrollable
   =========================================== */
.scroll-hint-container {
  position: relative;
}

.scroll-hint-container::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 40px;
  background: linear-gradient(to right, transparent, rgba(255,255,255,0.9));
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.scroll-hint-container.scrolled-right::after {
  opacity: 0;
}

/* ===========================================
   Mobile-First Button Styles
   =========================================== */
@media (max-width: 767px) {
  .responsive-btn {
    width: 100%;
    padding: 14px 20px;
    font-size: 16px; /* Prevents iOS zoom on focus */
  }

  .responsive-btn-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .responsive-btn-group > * {
    width: 100%;
  }
}

/* ===========================================
   Prevent Body Horizontal Overflow
   =========================================== */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

/* ===========================================
   Safe Area Insets (for notched devices)
   =========================================== */
@supports (padding: env(safe-area-inset-bottom)) {
  .safe-area-bottom {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .safe-area-top {
    padding-top: env(safe-area-inset-top);
  }
}

/* ===========================================
   Mobile Line Break
   Shows line break only on mobile
   =========================================== */
.mobile-break {
  display: none;
}

@media (max-width: 600px) {
  .mobile-break {
    display: block;
  }
}

/* Footer line break should always show */
footer .mobile-break {
  display: block;
}
