/* ========================================
   MOBILE OPTIMIZATIONS
   Additional mobile-specific improvements
   ======================================== */

/* ========== MOBILE PERFORMANCE OPTIMIZATIONS ========== */

/* Reduce animations on mobile for better performance */
@media (max-width: 768px) {
  * {
    animation-duration: 0.2s !important;
    transition-duration: 0.2s !important;
  }
  
  /* Disable complex animations on mobile */
  .hero-content {
    animation: none;
  }
  
  /* Simplify hover effects for touch devices */
  .menu-card:hover,
  .stat-card:hover,
  .guru-card:hover {
    transform: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  }
}

/* ========== TOUCH OPTIMIZATIONS ========== */

/* Better touch feedback */
@media (max-width: 768px) {
  .btn,
  .menu-card,
  .stat-card,
  .nav-item,
  .notification-icon {
    -webkit-tap-highlight-color: rgba(28, 71, 45, 0.1);
    /* tap-highlight-color is only supported with -webkit- prefix */
  }
  
  /* Active states for touch */
  .btn:active,
  .menu-card:active,
  .stat-card:active {
    transform: scale(0.98);
    opacity: 0.9;
  }
  
  /* Prevent text selection on interactive elements */
  .btn,
  .menu-card,
  .stat-card,
  .nav-item {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
  }
}

/* ========== MOBILE TYPOGRAPHY IMPROVEMENTS ========== */

@media (max-width: 768px) {
  /* Improve readability on mobile */
  body {
    font-size: 16px;
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }
  
  /* Better heading hierarchy */
  h1 {
    font-size: clamp(1.5rem, 5vw, 2rem);
    line-height: 1.2;
    margin-bottom: 1rem;
  }
  
  h2 {
    font-size: clamp(1.25rem, 4vw, 1.5rem);
    line-height: 1.3;
    margin-bottom: 0.875rem;
  }
  
  h3 {
    font-size: clamp(1.125rem, 3.5vw, 1.25rem);
    line-height: 1.4;
    margin-bottom: 0.75rem;
  }
  
  /* Better paragraph spacing */
  p {
    margin-bottom: 1rem;
    max-width: none;
  }
  
  /* Improve link readability */
  a {
    text-decoration-thickness: 2px;
    text-underline-offset: 2px;
  }
}

/* ========== MOBILE FORM IMPROVEMENTS ========== */

@media (max-width: 768px) {
  /* Prevent zoom on input focus */
  input,
  select,
  textarea {
    font-size: 16px !important;
    -webkit-appearance: none;
    appearance: none;
  }
  
  /* Better form spacing */
  .input-group {
    margin-bottom: 1.5rem;
  }
  
  /* Larger touch targets for form elements */
  input,
  select,
  textarea,
  button {
    min-height: 44px;
    padding: 0.75rem 1rem;
  }
  
  /* Better checkbox and radio styling */
  input[type="checkbox"],
  input[type="radio"] {
    min-width: 20px;
    min-height: 20px;
    margin-right: 0.5rem;
  }
}

/* ========== MOBILE NAVIGATION ENHANCEMENTS ========== */

@media (max-width: 768px) {
  /* Smooth mobile menu animation */
  .menu-nav {
    transform: translateY(-10px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  .menu-nav.mobile-open {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
  }
  
  /* Better mobile menu item spacing */
  .nav-link {
    padding: 1rem 1.5rem;
    margin: 0.25rem 0;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
  }
  
  /* Mobile breadcrumb improvements */
  .breadcrumb {
    font-size: 0.875rem;
    padding: 0.5rem 0;
    overflow-x: auto;
    white-space: nowrap;
  }
}

/* ========== MOBILE TABLE IMPROVEMENTS ========== */

@media (max-width: 768px) {
  /* Responsive table wrapper */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }
  
  /* Mobile table styling */
  table {
    min-width: 600px;
    font-size: 0.875rem;
  }
  
  th,
  td {
    padding: 0.75rem 0.5rem;
    white-space: nowrap;
  }
  
  /* Table scroll indicator */
  .table-wrapper::after {
    content: '← Scroll untuk melihat lebih banyak';
    display: block;
    text-align: center;
    font-size: 0.75rem;
    color: #6b7280;
    padding: 0.5rem;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
  }
}

/* ========== MOBILE MODAL IMPROVEMENTS ========== */

@media (max-width: 768px) {
  .modal-overlay {
    padding: 1rem;
    align-items: flex-end;
  }
  
  .modal-content {
    width: 100%;
    max-width: none;
    margin: 0;
    border-radius: 16px 16px 0 0;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
  }
  
  @keyframes slideUp {
    from {
      transform: translateY(100%);
    }
    to {
      transform: translateY(0);
    }
  }
  
  /* Modal close button */
  .modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }
}

/* ========== MOBILE LOADING STATES ========== */

@media (max-width: 768px) {
  /* Loading spinner */
  .loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
  }
  
  @keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
  }
  
  /* Loading overlay */
  .loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
  }
}

/* ========== MOBILE ACCESSIBILITY IMPROVEMENTS ========== */

@media (max-width: 768px) {
  /* Focus indicators */
  *:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
  }
  
  /* Skip links */
  .skip-link:focus {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 10000;
    padding: 0.75rem 1rem;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
  }
  
  /* Screen reader only content */
  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}

/* ========== MOBILE DARK MODE OPTIMIZATIONS ========== */

@media (max-width: 768px) {
  html[data-theme="dark"] {
    /* Darker backgrounds for better battery life on OLED */
    --light-color: #000000;
    --glass-light: rgba(255, 255, 255, 0.05);
  }
  
  html[data-theme="dark"] .modal-content {
    background: #1a1a1a;
    color: #e5e7eb;
  }
  
  html[data-theme="dark"] .table-wrapper::after {
    background: #1f2937;
    color: #9ca3af;
    border-top-color: #374151;
  }
}

/* ========== MOBILE PRINT OPTIMIZATIONS ========== */

@media print {
  /* Hide mobile-specific elements */
  .hamburger,
  .hamburger-menu,
  .sidebar-overlay,
  .mobile-only {
    display: none !important;
  }
  
  /* Optimize layout for print */
  .main-content {
    margin: 0 !important;
    padding: 0 !important;
  }
  
  /* Better typography for print */
  body {
    font-size: 12pt;
    line-height: 1.4;
    color: #000;
  }
}

/* ========== MOBILE LANDSCAPE OPTIMIZATIONS ========== */

@media (max-width: 768px) and (orientation: landscape) {
  /* Adjust heights for landscape */
  .hero {
    min-height: 60vh;
  }
  
  .navbar,
  .top-bar {
    height: 3rem;
  }
  
  /* Compact navigation */
  .nav-link {
    padding: 0.5rem 1rem;
  }
  
  /* Better use of horizontal space */
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  
  .menu-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

/* ========== MOBILE SPECIFIC UTILITIES ========== */

@media (max-width: 768px) {
  /* Mobile-only display utilities */
  .mobile-only {
    display: block !important;
  }
  
  .desktop-only {
    display: none !important;
  }
  
  /* Mobile spacing utilities */
  .mobile-p-1 { padding: 0.25rem !important; }
  .mobile-p-2 { padding: 0.5rem !important; }
  .mobile-p-3 { padding: 1rem !important; }
  .mobile-p-4 { padding: 1.5rem !important; }
  
  .mobile-m-1 { margin: 0.25rem !important; }
  .mobile-m-2 { margin: 0.5rem !important; }
  .mobile-m-3 { margin: 1rem !important; }
  .mobile-m-4 { margin: 1.5rem !important; }
  
  /* Mobile text utilities */
  .mobile-text-center { text-align: center !important; }
  .mobile-text-left { text-align: left !important; }
  .mobile-text-right { text-align: right !important; }
  
  /* Mobile flex utilities */
  .mobile-flex-column { flex-direction: column !important; }
  .mobile-flex-row { flex-direction: row !important; }
  .mobile-justify-center { justify-content: center !important; }
  .mobile-align-center { align-items: center !important; }
}