/* ============================================
   🎨 MODERN iOS STYLE CSS
   Dark Mode + Responsive + Smooth Animation
   ============================================ */

/* ---------- CSS Variables ---------- */
:root {
  /* Light Mode Colors */
  --bg-primary: #f2f2f7;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e5e5ea;
  --text-primary: #000000;
  --text-secondary: #3c3c43;
  --text-tertiary: #8e8e93;
  --accent-color: #007aff;
  --accent-secondary: #5856d6;
  --success-color: #34c759;
  --warning-color: #ff9500;
  --danger-color: #ff3b30;
  --border-color: rgba(60, 60, 67, 0.1);
  --card-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.5);
  
  /* Sizing */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  
  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  
  /* Animation */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* ---------- Dark Mode Colors ---------- */
[data-bs-theme="dark"], 
.dark-mode {
  --bg-primary: #000000;
  --bg-secondary: #1c1c1e;
  --bg-tertiary: #2c2c2e;
  --text-primary: #ffffff;
  --text-secondary: #ebebf5;
  --text-tertiary: #8e8e93;
  --border-color: rgba(84, 84, 88, 0.65);
  --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  --glass-bg: rgba(28, 28, 30, 0.72);
  --glass-border: rgba(255, 255, 255, 0.1);
}

/* ---------- Base Styles ---------- */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Sarabun', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  transition: background-color var(--transition-normal), color var(--transition-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-md);
}

.text-gradient {
  background: linear-gradient(135deg, var(--accent-color), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ---------- iOS Card Style ---------- */
.ios-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--card-shadow);
  transition: all var(--transition-normal);
  border: 1px solid var(--border-color);
}

.ios-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.ios-card-flat {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  border: 1px solid var(--border-color);
}

/* ---------- Glass Morphism ---------- */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
}

/* ---------- iOS Navigation Bar ---------- */
.ios-navbar {
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 0.5px solid var(--border-color);
  padding: var(--space-sm) var(--space-md);
  position: sticky;
  top: 0;
  z-index: 1000;
  transition: all var(--transition-normal);
}

.ios-navbar .nav-link {
  color: var(--accent-color);
  font-weight: 500;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.ios-navbar .nav-link:hover {
  background: rgba(0, 122, 255, 0.1);
}

.ios-navbar .nav-link.active {
  background: var(--accent-color);
  color: white;
}

/* ---------- iOS Buttons ---------- */
.ios-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 16px;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
  text-decoration: none;
}

.ios-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.2) 0%, transparent 100%);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.ios-btn:hover::before {
  opacity: 1;
}

.ios-btn:active {
  transform: scale(0.97);
}

.ios-btn-primary {
  background: var(--accent-color);
  color: white;
}

.ios-btn-primary:hover {
  background: #0066d6;
  color: white;
}

.ios-btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.ios-btn-success {
  background: var(--success-color);
  color: white;
}

.ios-btn-warning {
  background: var(--warning-color);
  color: white;
}

.ios-btn-danger {
  background: var(--danger-color);
  color: white;
}

.ios-btn-ghost {
  background: transparent;
  color: var(--accent-color);
}

.ios-btn-ghost:hover {
  background: rgba(0, 122, 255, 0.1);
}

/* Small button */
.ios-btn-sm {
  padding: 8px 16px;
  font-size: 14px;
  border-radius: var(--radius-sm);
}

/* Large button */
.ios-btn-lg {
  padding: 16px 32px;
  font-size: 18px;
  border-radius: var(--radius-lg);
}

/* Full width button */
.ios-btn-block {
  width: 100%;
}

/* ---------- iOS Form Elements ---------- */
.ios-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  background: var(--bg-tertiary);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  transition: all var(--transition-fast);
  outline: none;
}

.ios-input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.15);
}

.ios-input::placeholder {
  color: var(--text-tertiary);
}

.ios-select {
  width: 100%;
  padding: 14px 40px 14px 16px;
  font-size: 16px;
  background: var(--bg-tertiary);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.ios-select:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.15);
  outline: none;
}

/* iOS Toggle Switch */
.ios-toggle {
  position: relative;
  width: 51px;
  height: 31px;
  cursor: pointer;
}

.ios-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.ios-toggle-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  transition: all var(--transition-normal);
}

.ios-toggle-slider::before {
  content: '';
  position: absolute;
  width: 27px;
  height: 27px;
  left: 2px;
  bottom: 2px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: all var(--transition-normal);
}

.ios-toggle input:checked + .ios-toggle-slider {
  background: var(--success-color);
}

.ios-toggle input:checked + .ios-toggle-slider::before {
  transform: translateX(20px);
}

/* ---------- iOS List Style ---------- */
.ios-list {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.ios-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  border-bottom: 0.5px solid var(--border-color);
  transition: background var(--transition-fast);
}

.ios-list-item:last-child {
  border-bottom: none;
}

.ios-list-item:hover {
  background: var(--bg-tertiary);
}

.ios-list-item:active {
  background: var(--bg-tertiary);
}

/* ---------- iOS Badge ---------- */
.ios-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-full);
  background: var(--accent-color);
  color: white;
}

.ios-badge-success {
  background: var(--success-color);
}

.ios-badge-warning {
  background: var(--warning-color);
}

.ios-badge-danger {
  background: var(--danger-color);
}

/* ---------- iOS Alert / Notification ---------- */
.ios-alert {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  border-left: 4px solid var(--accent-color);
  animation: slideInRight 0.3s var(--spring);
}

.ios-alert-success {
  border-left-color: var(--success-color);
  background: rgba(52, 199, 89, 0.1);
}

.ios-alert-warning {
  border-left-color: var(--warning-color);
  background: rgba(255, 149, 0, 0.1);
}

.ios-alert-danger {
  border-left-color: var(--danger-color);
  background: rgba(255, 59, 48, 0.1);
}

/* ---------- iOS Modal ---------- */
.ios-modal-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: 9999;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.ios-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.ios-modal {
  background: var(--bg-secondary);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  max-width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.9) translateY(20px);
  transition: transform var(--transition-slow);
}

.ios-modal-overlay.active .ios-modal {
  transform: scale(1) translateY(0);
}

/* ---------- iOS Table ---------- */
.ios-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.ios-table th {
  background: var(--bg-tertiary);
  padding: var(--space-md);
  font-weight: 600;
  text-align: left;
  font-size: 14px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ios-table td {
  padding: var(--space-md);
  border-bottom: 0.5px solid var(--border-color);
}

.ios-table tr:last-child td {
  border-bottom: none;
}

.ios-table tr:hover td {
  background: var(--bg-tertiary);
}

/* ---------- Animations ---------- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Animation Classes */
.animate-fadeIn { animation: fadeIn 0.5s ease; }
.animate-slideInUp { animation: slideInUp 0.5s var(--spring); }
.animate-slideInRight { animation: slideInRight 0.5s var(--spring); }
.animate-slideInDown { animation: slideInDown 0.5s var(--spring); }
.animate-scaleIn { animation: scaleIn 0.3s var(--spring); }
.animate-pulse { animation: pulse 2s infinite; }

/* Staggered animation */
.stagger-animation > * {
  opacity: 0;
  animation: slideInUp 0.5s var(--spring) forwards;
}

.stagger-animation > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-animation > *:nth-child(2) { animation-delay: 0.1s; }
.stagger-animation > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-animation > *:nth-child(4) { animation-delay: 0.2s; }
.stagger-animation > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-animation > *:nth-child(6) { animation-delay: 0.3s; }
.stagger-animation > *:nth-child(7) { animation-delay: 0.35s; }
.stagger-animation > *:nth-child(8) { animation-delay: 0.4s; }

/* Loading Skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-secondary) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

/* Loading Spinner */
.ios-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ---------- Responsive Design ---------- */
/* Mobile First Approach */

/* Extra Small devices (phones, less than 576px) */
@media (max-width: 575.98px) {
  :root {
    --space-lg: 16px;
    --space-xl: 24px;
  }
  
  body {
    font-size: 14px;
  }
  
  .ios-card {
    border-radius: var(--radius-md);
    padding: var(--space-md);
  }
  
  .ios-btn {
    padding: 10px 16px;
    font-size: 14px;
  }
  
  .ios-navbar {
    padding: var(--space-xs) var(--space-sm);
  }
  
  .ios-navbar .nav-link {
    padding: var(--space-xs) var(--space-sm);
    font-size: 13px;
  }
  
  .container {
    padding-left: var(--space-md);
    padding-right: var(--space-md);
  }
  
  .ios-table {
    font-size: 13px;
  }
  
  .ios-table th,
  .ios-table td {
    padding: var(--space-sm);
  }
  
  /* Stack buttons on mobile */
  .btn-group-mobile {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
  }
  
  .btn-group-mobile .ios-btn {
    width: 100%;
  }
  
  /* Hide on mobile */
  .hide-mobile {
    display: none !important;
  }
}

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) {
  .container {
    max-width: 540px;
  }
  
  .show-mobile-only {
    display: none !important;
  }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) {
  .container {
    max-width: 720px;
  }
  
  .ios-card {
    padding: var(--space-xl);
  }
  
  /* Two column on tablet */
  .grid-tablet-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
  }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {
  .container {
    max-width: 960px;
  }
  
  /* Three column on desktop */
  .grid-desktop-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-lg);
  }
  
  /* Four column on desktop */
  .grid-desktop-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-lg);
  }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
  .container {
    max-width: 1140px;
  }
}

/* ---------- Utility Classes ---------- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-tertiary); }
.text-accent { color: var(--accent-color); }
.text-success { color: var(--success-color); }
.text-warning { color: var(--warning-color); }
.text-danger { color: var(--danger-color); }

.bg-primary { background: var(--bg-primary); }
.bg-secondary { background: var(--bg-secondary); }
.bg-tertiary { background: var(--bg-tertiary); }

.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-full { border-radius: var(--radius-full); }

.shadow { box-shadow: var(--card-shadow); }
.shadow-lg { box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15); }

.m-0 { margin: 0; }
.p-0 { padding: 0; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.p-sm { padding: var(--space-sm); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }

.w-full { width: 100%; }
.h-full { height: 100%; }

.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }

.cursor-pointer { cursor: pointer; }
.select-none { user-select: none; }

/* Hover effects */
.hover-lift {
  transition: transform var(--transition-fast);
}
.hover-lift:hover {
  transform: translateY(-4px);
}

.hover-scale {
  transition: transform var(--transition-fast);
}
.hover-scale:hover {
  transform: scale(1.02);
}

.hover-glow:hover {
  box-shadow: 0 0 20px rgba(0, 122, 255, 0.3);
}

/* Focus visible for accessibility */
.ios-btn:focus-visible,
.ios-input:focus-visible,
.ios-select:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb {
  background: var(--text-tertiary);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* Print styles */
@media print {
  .ios-navbar,
  .ios-btn,
  .no-print {
    display: none !important;
  }
  
  body {
    background: white;
    color: black;
  }
  
  .ios-card {
    box-shadow: none;
    border: 1px solid #ccc;
  }
}


