/* =====================================================
   ALUMNI MANAGEMENT SYSTEM - Mobile Responsiveness
   Comprehensive responsive design for all screen sizes
   ===================================================== */

/* =====================================================
   MOBILE FIRST - BASE STYLES
   ===================================================== */

/* Ensure all containers are responsive */
* {
  min-width: 0;
  min-height: 0;
}

/* Prevent horizontal scroll */
html,
body {
  overflow-x: hidden;
  max-width: 100vw;
}

/* =====================================================
   DASHBOARD LAYOUT - RESPONSIVE
   ===================================================== */

@media (max-width: 1024px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    bottom: 0;
    width: 280px;
    z-index: 100;
    transition: left 0.3s ease;
  }

  .sidebar.active {
    left: 0;
  }

  .main-content {
    margin-left: 0;
  }

  /* Sidebar overlay */
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    display: none;
  }

  .sidebar-overlay.active {
    display: block;
  }
}

/* =====================================================
   HEADER / TOPBAR - RESPONSIVE
   ===================================================== */

@media (max-width: 768px) {
  .content-header,
  .topbar,
  .admin-topbar {
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
  }

  .page-title {
    font-size: 1.25rem !important;
  }

  .content-header .btn,
  .topbar .btn,
  .admin-topbar .btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
  }
}

@media (max-width: 480px) {
  .page-title {
    font-size: 1.125rem !important;
  }

  .sidebar-toggle {
    padding: 0.5rem !important;
  }
}

/* =====================================================
   CARDS - RESPONSIVE
   ===================================================== */

@media (max-width: 768px) {
  .card {
    border-radius: 0.75rem;
  }

  .card-header,
  .card-body,
  .card-footer {
    padding: 1rem;
  }

  .card-title {
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .card-header,
  .card-body,
  .card-footer {
    padding: 0.875rem;
  }
}

/* =====================================================
   GRID LAYOUTS - RESPONSIVE
   ===================================================== */

@media (max-width: 1024px) {
  .grid-cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-cols-6 {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: 1fr;
  }

  .grid-cols-6 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .grid-cols-6 {
    grid-template-columns: 1fr;
  }
}

/* =====================================================
   FORMS - RESPONSIVE
   ===================================================== */

@media (max-width: 768px) {
  .form-grid {
    grid-template-columns: 1fr !important;
  }

  .form-row {
    grid-template-columns: 1fr !important;
  }

  .form-input,
  .form-select,
  .form-textarea {
    font-size: 16px; /* Prevent zoom on iOS */
  }
}

/* =====================================================
   TABLES - RESPONSIVE
   ===================================================== */

@media (max-width: 1024px) {
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table,
  .data-table {
    min-width: 600px;
  }
}

@media (max-width: 768px) {
  .table th,
  .table td,
  .data-table th,
  .data-table td {
    padding: 0.75rem 0.5rem;
    font-size: 0.8125rem;
  }

  /* Stack table on very small screens */
  .table-responsive-stack {
    display: block;
  }

  .table-responsive-stack thead {
    display: none;
  }

  .table-responsive-stack tbody,
  .table-responsive-stack tr,
  .table-responsive-stack td {
    display: block;
    width: 100%;
  }

  .table-responsive-stack tr {
    margin-bottom: 1rem;
    border: 1px solid var(--gray-200);
    border-radius: 0.5rem;
    padding: 0.75rem;
  }

  .table-responsive-stack td {
    text-align: right;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--gray-100);
  }

  .table-responsive-stack td:last-child {
    border-bottom: none;
  }

  .table-responsive-stack td::before {
    content: attr(data-label);
    float: left;
    font-weight: 600;
    color: var(--gray-700);
  }
}

/* =====================================================
   MODALS - RESPONSIVE
   ===================================================== */

@media (max-width: 768px) {
  .modal[id],
  .modal-overlay {
    padding: 0.5rem;
  }

  .modal[id] .modal-dialog,
  .modal-overlay > .modal {
    max-width: 100%;
    max-height: calc(100vh - 1rem);
  }

  .modal[id] .modal-content {
    border-radius: 1rem;
  }

  .modal-header {
    padding: 1rem;
  }

  .modal-title {
    font-size: 1.25rem;
  }

  .modal-body {
    padding: 1rem;
  }

  .modal-footer {
    padding: 1rem;
    flex-wrap: wrap;
  }

  .modal-footer .btn {
    flex: 1 1 45%;
    min-width: 0;
  }
}

@media (max-width: 480px) {
  .modal-footer .btn {
    flex: 1 1 100%;
  }
}

/* =====================================================
   BUTTONS - RESPONSIVE
   ===================================================== */

@media (max-width: 768px) {
  .btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
  }

  .btn-sm {
    padding: 0.375rem 0.625rem;
    font-size: 0.8125rem;
  }

  .btn-lg {
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
  }

  .btn-group {
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  .btn-block-mobile {
    width: 100%;
    display: block;
  }
}

/* =====================================================
   NAVIGATION - RESPONSIVE
   ===================================================== */

@media (max-width: 768px) {
  .tabs-list {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .tabs-list::-webkit-scrollbar {
    display: none;
  }

  .tab,
  .tab-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
  }
}

/* =====================================================
   PROFILE PAGE - RESPONSIVE
   ===================================================== */

@media (max-width: 1024px) {
  .profile-hero-grid {
    flex-direction: column;
  }

  .profile-points-card {
    width: 100%;
  }

  .profile-meta-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .profile-page {
    padding: 0.5rem;
  }

  .profile-meta-grid {
    grid-template-columns: 1fr;
  }

  .profile-tabs {
    width: 100%;
    overflow-x: auto;
  }

  .profile-tabs .tab {
    flex: 1;
    min-width: 80px;
    font-size: 0.8125rem;
  }
}

/* =====================================================
   QR SCANNER - RESPONSIVE
   ===================================================== */

@media (max-width: 768px) {
  .scanner-container {
    max-width: 100%;
  }

  #qrReader {
    min-height: 300px;
  }

  .scanner-frame {
    width: 200px;
    height: 200px;
  }

  .scanner-instruction {
    font-size: 0.8125rem;
    padding: 0.375rem 0.75rem;
  }
}

@media (max-width: 480px) {
  #qrReader {
    min-height: 250px;
  }

  .scanner-frame {
    width: 180px;
    height: 180px;
  }
}

/* =====================================================
   DASHBOARD STATS - RESPONSIVE
   ===================================================== */

@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stat-card {
    padding: 1rem;
  }
}

/* =====================================================
   FILTERS BAR - RESPONSIVE
   ===================================================== */

@media (max-width: 768px) {
  .filters-bar {
    flex-direction: column;
  }

  .filters-bar > * {
    width: 100%;
    min-width: 0;
  }
}

/* =====================================================
   TOAST NOTIFICATIONS - RESPONSIVE
   ===================================================== */

@media (max-width: 768px) {
  .toast-container {
    top: 0.5rem;
    right: 0.5rem;
    left: 0.5rem;
    width: auto;
  }

  .toast {
    padding: 0.75rem;
  }

  .toast-message {
    font-size: 0.8125rem;
  }
}

/* =====================================================
   LANDING PAGE - RESPONSIVE
   ===================================================== */

@media (max-width: 1024px) {
  .hero-section {
    padding: 3rem 1rem;
  }

  .hero-title {
    font-size: 2.5rem;
  }

  .features-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .hero-section {
    padding: 2rem 1rem;
  }

  .hero-title {
    font-size: 2rem;
  }

  .hero-subtitle {
    font-size: 1rem;
  }

  .features-grid,
  .steps-grid {
    grid-template-columns: 1fr;
  }

  .landing-nav {
    padding: 1rem;
  }
}

/* =====================================================
   AUTH PAGES - RESPONSIVE
   ===================================================== */

@media (max-width: 768px) {
  .auth-card {
    padding: 1.5rem;
    margin: 1rem;
  }

  .auth-title {
    font-size: 1.5rem;
  }

  .auth-logo {
    width: 60px;
    height: 60px;
  }
}

@media (max-width: 480px) {
  .auth-card {
    padding: 1.25rem;
    margin: 0.5rem;
  }

  .auth-title {
    font-size: 1.25rem;
  }
}

/* =====================================================
   COMPLETE PROFILE WIZARD - RESPONSIVE
   ===================================================== */

@media (max-width: 768px) {
  .profile-wizard {
    margin: 0.5rem auto;
    border-radius: 0.75rem;
  }

  .wizard-header {
    padding: 1rem;
  }

  .wizard-header h1 {
    font-size: 1.25rem !important;
  }

  .wizard-header p {
    font-size: 0.8125rem !important;
  }

  .wizard-progress {
    padding: 0.75rem 1rem;
  }

  .progress-step {
    font-size: 0.6875rem;
  }

  .progress-step span {
    display: none;
  }

  .wizard-step {
    padding: 1rem;
  }

  .step-title {
    font-size: 1.125rem;
  }

  .step-description {
    font-size: 0.8125rem;
  }

  .wizard-nav {
    padding: 1rem;
    gap: 0.5rem;
  }

  .wizard-nav .btn {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
  }
}

@media (max-width: 480px) {
  .wizard-header .auth-logo {
    width: 50px !important;
    height: 50px !important;
  }

  .points-badge {
    font-size: 0.75rem !important;
    padding: 6px 12px !important;
  }

  .wizard-nav {
    flex-wrap: wrap;
  }

  .wizard-nav button {
    flex: 1;
    min-width: 100px;
  }
}

/* =====================================================
   CONTENT WRAPPER - RESPONSIVE
   ===================================================== */

@media (max-width: 768px) {
  .content-wrapper {
    padding: 1rem;
  }

  .content-body {
    padding: 1rem;
  }
}

@media (max-width: 480px) {
  .content-wrapper {
    padding: 0.75rem;
  }

  .content-body {
    padding: 0.75rem;
  }
}

/* =====================================================
   UTILITY CLASSES - RESPONSIVE
   ===================================================== */

/* Hide on mobile */
@media (max-width: 768px) {
  .hide-mobile {
    display: none !important;
  }
}

/* Show only on mobile */
.show-mobile {
  display: none !important;
}

@media (max-width: 768px) {
  .show-mobile {
    display: block !important;
  }

  .show-mobile-flex {
    display: flex !important;
  }

  .show-mobile-inline {
    display: inline !important;
  }
}

/* Text alignment responsive */
@media (max-width: 768px) {
  .text-center-mobile {
    text-align: center !important;
  }

  .text-left-mobile {
    text-align: left !important;
  }
}

/* Spacing responsive */
@media (max-width: 768px) {
  .p-lg {
    padding: 1rem !important;
  }

  .p-xl {
    padding: 1.25rem !important;
  }

  .mt-lg {
    margin-top: 1rem !important;
  }

  .mb-lg {
    margin-bottom: 1rem !important;
  }
}

/* =====================================================
   TOUCH IMPROVEMENTS
   ===================================================== */

/* Larger touch targets on mobile */
@media (max-width: 768px) {
  .btn,
  .form-input,
  .form-select,
  .tab,
  .dropdown-item {
    min-height: 44px; /* iOS recommended touch target */
  }

  /* Prevent text selection on buttons */
  .btn,
  .tab,
  .dropdown-item {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
  }
}

/* =====================================================
   SAFE AREA INSETS (for notched devices)
   ===================================================== */

@supports (padding: max(0px)) {
  .content-header,
  .topbar,
  .admin-topbar {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }

  .sidebar {
    padding-left: max(1rem, env(safe-area-inset-left));
  }

  .modal[id],
  .modal-overlay {
    padding-left: max(0.5rem, env(safe-area-inset-left));
    padding-right: max(0.5rem, env(safe-area-inset-right));
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
  }
}

/* =====================================================
   PRINT STYLES
   ===================================================== */

@media print {
  .sidebar,
  .sidebar-toggle,
  .btn,
  .filters-bar,
  .pagination,
  .no-print {
    display: none !important;
  }

  .main-content {
    margin-left: 0 !important;
  }

  .card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
  }

  .table {
    font-size: 10pt;
  }
}

/* =====================================================
   ACCESSIBILITY IMPROVEMENTS
   ===================================================== */

/* Focus visible improvements for keyboard navigation */
@media (max-width: 768px) {
  *:focus-visible {
    outline: 3px solid var(--color-primary);
    outline-offset: 2px;
  }
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
