/**
 * Guru Les Additional Styles
 * File ini berisi custom styles tambahan untuk aplikasi
 * Dimuat setelah critical.css untuk progressive enhancement
 */

/**
 * Base Overrides
 * Override default browser styles
 */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Container untuk consistency dengan index.php asli */
.container-page {
  max-width: 1140px;
  margin: 0 auto;
}

/* Modern Select Dropdown Style */
.modern-select-wrapper {
  position: relative;
}

.modern-select-wrapper select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%232563eb' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 20px;
  padding-right: 2.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.modern-select-wrapper select:hover {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.modern-select-wrapper select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  background-color: #fefefe;
}

.modern-select-wrapper select option {
  padding: 12px;
  background-color: #fff;
  color: #0f172a;
  font-size: 14px;
}

.modern-select-wrapper select option:hover,
.modern-select-wrapper select option:checked {
  background: linear-gradient(90deg, #eff6ff 0%, #dbeafe 100%);
  color: #1e40af;
}

.modern-select-wrapper select optgroup {
  font-weight: 600;
  color: #475569;
  font-size: 13px;
  padding: 8px 12px;
  background-color: #f8fafc;
}

/* Sticky footer layout */
.sticky-footer {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.sticky-footer main {
  flex: 1;
}

/* Focus styles untuk accessibility */
*:focus {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

/* Remove focus outline for mouse users */
.js-focus-visible :focus:not(.focus-visible) {
  outline: none;
}

/* Smooth scroll untuk browser yang support */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --text-primary: #000000;
    --text-secondary: #333333;
    --bg-primary: #ffffff;
    --border-color: #000000;
  }
}

/* Dark mode preparation (untuk future use) */
/* @media (prefers-color-scheme: dark) {
  :root {
    Dark mode akan di-implement nanti jika diperlukan
  }
} */

/**
 * Print Styles
 */
@media print {
  body {
    font-size: 12pt;
    line-height: 1.4;
    color: #000 !important;
    background: #fff !important;
  }
  
  .no-print {
    display: none !important;
  }
  
  .print-break {
    page-break-before: always;
  }
  
  .print-avoid-break {
    page-break-inside: avoid;
  }
  
  a[href^="http"]:after {
    content: " (" attr(href) ")";
    font-size: 10pt;
    color: #666;
  }
  
  .card-teacher,
  .card-category {
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    break-inside: avoid;
  }
}

/**
 * Selection Styles
 */
::selection {
  background: rgba(37, 99, 235, 0.2);
  color: inherit;
}

::-moz-selection {
  background: rgba(37, 99, 235, 0.2);
  color: inherit;
}

/**
 * Custom Scrollbar untuk Webkit
 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/**
 * Form Elements Base Styles
 */
input,
textarea,
select,
button {
  font-family: inherit;
  font-size: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/**
 * Link Styles
 */
a {
  color: var(--brand-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--brand-secondary);
}

a:focus {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

/**
 * Image Styles
 */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/**
 * Table Styles
 */
table {
  border-collapse: collapse;
  width: 100%;
}

th,
td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
}

th {
  font-weight: 600;
  color: var(--text-secondary);
  background: #f9fafb;
}

/**
 * Mobile Optimizations
 */
@media (max-width: 767px) {
  html {
    font-size: 14px;
  }
  
  body {
    -webkit-text-size-adjust: 100%;
  }
  
  /* Prevent zoom on input focus di iOS */
  input,
  textarea,
  select {
    font-size: 16px;
  }
}

/**
 * High DPI / Retina Optimizations
 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  /* Optimizations untuk layar retina */
  .icon,
  .logo {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/**
 * Accessibility Improvements
 */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--brand-primary);
  color: white;
  padding: 8px;
  text-decoration: none;
  border-radius: 4px;
  z-index: 1000;
}

.skip-link:focus {
  top: 6px;
}

/**
 * Utility Classes untuk Quick Fixes
 */
.clearfix::after {
  content: "";
  display: table;
  clear: both;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-clamp-1 {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  line-clamp: 1;
  -webkit-box-orient: vertical;
}

.line-clamp-2 {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

.line-clamp-3 {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
}

/**
 * Debug Mode (hanya untuk development)
 * Uncomment untuk debugging layout issues
 */
/*
.debug * {
  outline: 1px solid red;
}

.debug-grid {
  background-image: 
    linear-gradient(rgba(255,0,0,0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,0,0,0.1) 1px, transparent 1px);
  background-size: 20px 20px;
}
*/

/**
 * Progressive Enhancement Features
 * CSS untuk fitur-fitur JavaScript enhancement
 */

/* Lazy Loading States */
img[data-src] {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  min-height: 200px;
}

img.loading {
  opacity: 0.6;
}

img.loaded {
  animation: fadeIn 0.5s ease-in;
}

img.error {
  opacity: 0.5;
  filter: grayscale(100%);
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes fadeIn {
  from { 
    opacity: 0; 
    transform: scale(0.98);
  }
  to { 
    opacity: 1;
    transform: scale(1);
  }
}

/* Fade in animation for cards with lazy loading */
.tutor-card[data-lazy],
.card-teacher[data-lazy] {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.tutor-card.fade-in,
.card-teacher.fade-in {
  opacity: 1;
  transform: translateY(0);
}

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}



/* Notification toast */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  min-width: 300px;
  max-width: 500px;
  padding: 16px 20px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
  opacity: 0;
  transform: translateX(400px);
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.notification.show {
  opacity: 1;
  transform: translateX(0);
}

.notification.success { 
  border-left: 4px solid #10b981; 
  background: #f0fdf4;
}

.notification.error { 
  border-left: 4px solid #ef4444; 
  background: #fef2f2;
}

.notification.info { 
  border-left: 4px solid #3b82f6; 
  background: #eff6ff;
}

.notification.warning { 
  border-left: 4px solid #f59e0b; 
  background: #fffbeb;
}

.notification-message {
  flex: 1;
  font-size: 14px;
  line-height: 1.5;
  color: #1f2937;
}

.notification-close {
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: #6b7280;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s;
}

.notification-close:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #374151;
}

@media (max-width: 768px) {
  .notification {
    top: 10px;
    right: 10px;
    left: 10px;
    min-width: auto;
    transform: translateY(-100px);
  }
  
  .notification.show {
    transform: translateY(0);
  }
}

/* Search enhancements */
.clear-search {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 20px;
  color: #9ca3af;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s;
}

.clear-search:hover {
  background: #f3f4f6;
  color: #6b7280;
}

.clear-search.hidden {
  display: none;
}

/* Recent searches dropdown */
.recent-searches-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-top: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  z-index: 50;
  max-height: 300px;
  overflow-y: auto;
}

.dropdown-header {
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #e5e7eb;
}

.recent-searches-list {
  list-style: none;
  padding: 4px;
  margin: 0;
}

.recent-search-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.2s;
}

.recent-search-item:hover {
  background: #f3f4f6;
}

.recent-search-item .search-icon {
  font-size: 16px;
  opacity: 0.5;
}

.recent-search-item .search-text {
  flex: 1;
  font-size: 14px;
  color: #374151;
}

/* Loading overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.loading-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.loading-spinner {
  background: white;
  padding: 32px;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.loading-spinner .spinner {
  width: 40px;
  height: 40px;
  border-width: 3px;
  border-color: #e5e7eb;
  border-top-color: #3b82f6;
  margin: 0 auto 16px;
}

.loading-message {
  font-size: 14px;
  color: #6b7280;
  margin: 0;
}

/* Form loading state */
form.loading {
  opacity: 0.6;
  pointer-events: none;
}

form.loading button[type="submit"] {
  position: relative;
}

/* External link icon */
.external-icon {
  display: inline-block;
  margin-left: 2px;
}

/* App ready state - can be used for fade-in animations */
body:not(.app-ready) {
  opacity: 0;
}

body.app-ready {
  opacity: 1;
  transition: opacity 0.3s ease-in;
}

/* Smooth transitions for all interactive elements */
a, button, input, select, textarea {
  transition: all 0.2s ease;
}

/* Focus visible for keyboard navigation */
.focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .notification {
    transition: none;
  }
}
