/* ============================================================
   RESPONSIVE & MOBILE-FIRST DESIGN
   Complete mobile optimization for all devices
   ============================================================ */

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

/* Mobile menu panel - ALWAYS hidden by default on all screens */
.mobile-menu {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  display: none;
}

.mobile-menu.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

/* Hide desktop navigation on mobile */
@media (max-width: 768px) {
  .header-sticky .ml-10 {
    display: none;
  }

  /* Mobile menu toggle button */
  .mobile-menu-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
  }

  .mobile-menu-toggle svg {
    width: 24px;
    height: 24px;
    color: var(--color-gray-900);
  }

  .mobile-menu-content {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 80%;
    max-width: 320px;
    background: white;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.2);
    padding: 80px 24px 24px;
    overflow-y: auto;
    animation: slideInRight 0.3s ease;
  }

  @keyframes slideInRight {
    from {
      transform: translateX(100%);
    }
    to {
      transform: translateX(0);
    }
  }

  .mobile-menu-content a {
    display: block;
    padding: 16px 0;
    font-size: 18px;
    font-weight: 500;
    color: var(--color-gray-900);
    text-decoration: none;
    border-bottom: 1px solid var(--color-gray-200);
  }

  .mobile-menu-content a:hover {
    color: var(--color-primary);
  }
}

/* Show mobile toggle only on mobile */
.mobile-menu-toggle {
  display: none;
}

/* ============================================================
   RESPONSIVE TYPOGRAPHY
   ============================================================ */

/* Extra small devices (phones, less than 576px) */
@media (max-width: 575px) {
  h1 {
    font-size: 1.75rem !important;
    line-height: 1.2;
  }

  h2 {
    font-size: 1.5rem !important;
    line-height: 1.3;
  }

  h3 {
    font-size: 1.25rem !important;
    line-height: 1.3;
  }

  h4 {
    font-size: 1.125rem !important;
  }

  p {
    font-size: 0.9375rem;
    line-height: 1.6;
  }

  .text-3xl {
    font-size: 1.5rem !important;
  }

  .text-2xl {
    font-size: 1.25rem !important;
  }

  .text-xl {
    font-size: 1.125rem !important;
  }

  .text-lg {
    font-size: 1rem !important;
  }
}

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) and (max-width: 767px) {
  h1 {
    font-size: 2rem !important;
  }

  h2 {
    font-size: 1.75rem !important;
  }

  h3 {
    font-size: 1.5rem !important;
  }
}

/* ============================================================
   RESPONSIVE HEADER & NAVIGATION
   ============================================================ */

@media (max-width: 768px) {
  .header-sticky {
    width: 95%;
    top: 0.75rem;
    padding: 0;
  }

  .header-nav {
    padding: 0.5rem 1rem;
    min-height: 3.5rem;
    height: auto;
  }

  .header-logo {
    font-size: 1rem;
  }

  .header-logo span {
    font-size: 1rem;
  }

  .header-logo svg {
    width: 1.25rem;
    height: 1.25rem;
  }

  /* Hide user dropdown on mobile or simplify */
  .header-nav .flex.items-center.space-x-4 > div {
    font-size: 0.75rem;
  }

  .header-nav .w-8.h-8 {
    width: 2rem;
    height: 2rem;
  }
}

/* ============================================================
   RESPONSIVE SPACING & LAYOUT
   ============================================================ */

@media (max-width: 768px) {
  /* Reduce padding on containers */
  .max-w-7xl {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .px-4 {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .py-8 {
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
  }

  .py-12 {
    padding-top: 2rem;
    padding-bottom: 2rem;
  }

  /* Reduce gaps */
  .gap-6 {
    gap: 1rem;
  }

  .gap-8 {
    gap: 1.5rem;
  }

  .space-x-8 > * + * {
    margin-left: 1rem;
  }

  /* Reduce header spacer */
  div[style*="height: 100px"] {
    height: 70px !important;
  }
}

/* ============================================================
   RESPONSIVE CARDS & GRIDS
   ============================================================ */

@media (max-width: 768px) {
  /* Force single column on mobile */
  .grid.grid-cols-1.md\\:grid-cols-3,
  .grid.grid-cols-1.md\\:grid-cols-4 {
    grid-template-columns: 1fr !important;
  }

  /* Card adjustments */
  .card {
    padding: 1rem;
  }

  .bg-white.rounded-xl {
    padding: 1rem;
  }

  /* Stats cards */
  .grid-cols-1.md\\:grid-cols-4.gap-6 {
    gap: 0.75rem;
  }

  /* Make cards more compact */
  .p-6 {
    padding: 1rem !important;
  }

  .p-20 {
    padding: 2rem !important;
  }

  .p-16 {
    padding: 1.5rem !important;
  }
}

/* ============================================================
   RESPONSIVE BUTTONS & FORMS
   ============================================================ */

@media (max-width: 768px) {
  /* Make buttons full width or stack properly */
  .flex.space-x-3 {
    flex-direction: column;
    gap: 0.75rem;
  }

  .flex.space-x-3 > * {
    margin-left: 0 !important;
    width: 100%;
  }

  /* Ensure touch-friendly button sizes */
  button,
  .btn,
  a.btn {
    min-height: 44px;
    padding: 0.75rem 1rem;
    font-size: 1rem;
  }

  /* Form inputs */
  input,
  select,
  textarea {
    font-size: 16px !important; /* Prevents zoom on iOS */
    padding: 0.75rem;
  }

  /* Search bar */
  input[type="text"].w-64 {
    width: 100% !important;
  }

  /* Form groups */
  .flex.gap-3 {
    flex-direction: column;
    gap: 0.75rem;
  }

  .flex.gap-3 > * {
    width: 100% !important;
  }
}

/* ============================================================
   RESPONSIVE FOOTER
   ============================================================ */

@media (max-width: 768px) {
  footer {
    padding: 2rem 1rem !important;
    margin-top: 3rem !important;
  }

  footer .grid.grid-cols-1.md\\:grid-cols-3 {
    grid-template-columns: 1fr !important;
    gap: 2rem;
    text-align: center;
  }

  footer .space-y-2 {
    margin-top: 1rem;
  }

  footer .flex.items-center.gap-2 {
    justify-content: center;
  }
}

/* ============================================================
   RESPONSIVE TABLES & OVERFLOW
   ============================================================ */

@media (max-width: 768px) {
  /* Prevent horizontal scroll */
  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  /* Code blocks */
  pre,
  code {
    font-size: 0.75rem;
    overflow-x: auto;
  }

  /* API key display */
  .font-mono.text-xs.break-all {
    word-break: break-all;
    font-size: 0.7rem;
  }
}

/* ============================================================
   RESPONSIVE MODALS
   ============================================================ */

@media (max-width: 768px) {
  /* Full screen modals on mobile */
  .modal-backdrop,
  div[style*="background: rgba(0, 0, 0, 0.5)"] {
    padding: 0 !important;
  }

  .modal-content,
  div.relative.bg-white.rounded-lg {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 100vh;
    margin: 0 !important;
    border-radius: 0 !important;
  }

  /* Modal padding */
  .modal-content .p-6 {
    padding: 1.5rem !important;
  }
}

/* ============================================================
   RESPONSIVE BADGES & TAGS
   ============================================================ */

@media (max-width: 768px) {
  .badge,
  .bg-purple-100.text-purple-800 {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
  }

  /* Hide some badges on very small screens */
  @media (max-width: 400px) {
    .text-xs.bg-purple-100 {
      display: none;
    }
  }
}

/* ============================================================
   RESPONSIVE ACTIONS BAR
   ============================================================ */

@media (max-width: 768px) {
  /* Stack action bar items */
  .flex.flex-col.md\\:flex-row.md\\:justify-between {
    gap: 1rem;
  }

  .flex.items-center.space-x-3 {
    flex-wrap: wrap;
  }

  /* Make search and buttons stack */
  .flex.space-x-3 {
    width: 100%;
  }

  .flex.space-x-3 > .relative,
  .flex.space-x-3 > a {
    width: 100%;
  }
}

/* ============================================================
   RESPONSIVE STATS & METRICS
   ============================================================ */

@media (max-width: 768px) {
  /* Compact stat displays */
  .text-2xl.font-bold {
    font-size: 1.5rem !important;
  }

  .text-3xl.font-bold {
    font-size: 1.75rem !important;
  }

  .text-sm.font-medium {
    font-size: 0.813rem;
  }

  /* Icon sizes */
  .w-6.h-6 {
    width: 1.25rem;
    height: 1.25rem;
  }

  .p-3.rounded-full {
    padding: 0.625rem;
  }
}

/* ============================================================
   RESPONSIVE API DOCUMENTATION
   ============================================================ */

@media (max-width: 768px) {
  /* Code examples */
  .bg-gray-900.text-gray-100.p-4 {
    padding: 0.75rem !important;
    overflow-x: auto;
  }

  .bg-gray-900.text-gray-100.p-4 pre {
    font-size: 0.7rem;
    white-space: pre;
    overflow-x: auto;
  }
}

/* ============================================================
   RESPONSIVE PROJECT CARDS
   ============================================================ */

@media (max-width: 768px) {
  /* Project card grid */
  .grid.grid-cols-1.md\\:grid-cols-3.lg\\:grid-cols-3 {
    grid-template-columns: 1fr !important;
    gap: 1rem;
  }

  /* Project card actions */
  .flex.gap-2 {
    flex-wrap: wrap;
  }

  .flex.gap-2 > button,
  .flex.gap-2 > a {
    flex: 1;
    min-width: 0;
  }
}

/* ============================================================
   RESPONSIVE EMPTY STATES
   ============================================================ */

@media (max-width: 768px) {
  .p-20.text-center {
    padding: 2rem 1rem !important;
  }

  .w-16.h-16 {
    width: 3rem;
    height: 3rem;
  }

  .w-16.h-16 svg {
    width: 1.5rem;
    height: 1.5rem;
  }
}

/* ============================================================
   RESPONSIVE NOTIFICATIONS
   ============================================================ */

@media (max-width: 768px) {
  #notification-container {
    top: 1rem;
    right: 1rem;
    left: 1rem;
    max-width: 100%;
  }

  .max-w-sm {
    max-width: 100% !important;
  }

  .notification {
    font-size: 0.875rem;
  }
}

/* ============================================================
   RESPONSIVE UTILITY OVERRIDES
   ============================================================ */

@media (max-width: 768px) {
  /* Truncate long text */
  .truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Line clamp for descriptions */
  .line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  /* Prevent overflow */
  .min-w-0 {
    min-width: 0;
  }

  /* Hide on mobile */
  .hidden-mobile {
    display: none !important;
  }

  /* Show only on mobile */
  .show-mobile {
    display: block !important;
  }
}

/* ============================================================
   LANDSCAPE MOBILE OPTIMIZATIONS
   ============================================================ */

@media (max-width: 768px) and (orientation: landscape) {
  .header-sticky {
    top: 0.5rem;
  }

  .header-nav {
    min-height: 3rem;
    height: 3rem;
  }

  div[style*="height: 100px"],
  div[style*="height: 70px"] {
    height: 50px !important;
  }
}

/* ============================================================
   VERY SMALL DEVICES (< 400px)
   ============================================================ */

@media (max-width: 400px) {
  .header-logo span {
    font-size: 0.875rem;
  }

  .p-6 {
    padding: 0.75rem !important;
  }

  .p-4 {
    padding: 0.625rem !important;
  }

  button,
  .btn {
    font-size: 0.875rem;
    padding: 0.625rem 0.875rem;
  }

  /* Smaller icons */
  .w-4.h-4 {
    width: 0.875rem;
    height: 0.875rem;
  }
}

/* ============================================================
   TABLET OPTIMIZATIONS (768px - 1024px)
   ============================================================ */

@media (min-width: 768px) and (max-width: 1024px) {
  .max-w-7xl {
    padding-left: 2rem;
    padding-right: 2rem;
  }

  .grid.grid-cols-1.md\\:grid-cols-3 {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .grid.grid-cols-1.md\\:grid-cols-4 {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ============================================================
   TOUCH OPTIMIZATIONS
   ============================================================ */

@media (hover: none) and (pointer: coarse) {
  /* Increase touch targets */
  button,
  a,
  input,
  select {
    min-height: 44px;
    min-width: 44px;
  }

  /* Remove hover effects on touch devices */
  .card:hover,
  .btn:hover {
    transform: none;
  }

  /* Active states instead */
  .card:active {
    transform: scale(0.98);
  }

  .btn:active {
    transform: scale(0.96);
  }
}

/* ============================================================
   PRINT OPTIMIZATIONS
   ============================================================ */

@media print {
  .header-sticky,
  footer,
  button,
  .no-print {
    display: none !important;
  }

  .card {
    page-break-inside: avoid;
  }

  body {
    font-size: 12pt;
  }
}

/* ============================================================
   ACCESSIBILITY - SCREEN READERS
   ============================================================ */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ============================================================
   RESPONSIVE IMAGES & MEDIA
   ============================================================ */

@media (max-width: 768px) {
  img {
    max-width: 100%;
    height: auto;
  }

  svg {
    max-width: 100%;
  }

  iframe {
    max-width: 100%;
  }
}
