/* ===== MOBILE-FIRST RESPONSIVE DESIGN ===== */

/* Base reset */
*, *::before, *::after { 
  box-sizing: border-box; 
  margin: 0;
  padding: 0;
}

/* Base mobile styles (< 640px) */
body { 
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif; 
  margin: 0; 
  background: #0f172a; 
  color: #e2e8f0;
  font-size: clamp(14px, 2.5vw, 16px);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.wrap { 
  max-width: 100%;
  margin: 0 auto; 
  padding: 12px;
  width: 100%;
}

h1 { 
  margin: 8px 0 16px;
  font-size: clamp(1.5rem, 5vw, 2rem);
  line-height: 1.2;
}

h2 {
  font-size: clamp(1.25rem, 4vw, 1.5rem);
  line-height: 1.3;
}

h3 {
  font-size: clamp(1.1rem, 3vw, 1.25rem);
  line-height: 1.4;
}

/* PWA Refresh Button (floating) */
.pwa-refresh-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: all 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

.pwa-refresh-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(6, 182, 212, 0.6);
}

.pwa-refresh-btn:active {
  transform: scale(0.95);
}

.pwa-refresh-btn svg {
  animation: none;
}

.pwa-refresh-btn.refreshing svg {
  animation: spin 0.8s linear infinite;
}

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

/* Responsive adjustments */
@media (max-width: 640px) {
  .pwa-refresh-btn {
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
  }
}

.card { 
  background: #111827; 
  border: 1px solid #1f2937; 
  padding: 12px; 
  border-radius: 8px; 
  margin: 12px 0;
  overflow-x: auto;
}

label { 
  display: block; 
  margin: 12px 0 6px;
  font-size: 0.95rem;
}

input, select, textarea { 
  width: 100%; 
  padding: 12px; 
  border-radius: 8px; 
  border: 1px solid #334155; 
  background: #0b1220; 
  color: #e2e8f0;
  font-size: 16px;
  min-height: 44px;
  -webkit-appearance: none;
  appearance: none;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid #22c55e;
  outline-offset: 2px;
}

button, .btn { 
  margin-top: 14px; 
  padding: 12px 16px; 
  background: #22c55e; 
  color: #052e16; 
  font-weight: 700; 
  border: 0; 
  border-radius: 8px; 
  cursor: pointer;
  font-size: 16px;
  min-height: 44px;
  min-width: 44px;
  touch-action: manipulation;
  transition: all 0.2s;
  width: 100%;
}

button:hover, .btn:hover {
  background: #16a34a;
  transform: translateY(-1px);
}

button:active, .btn:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.result h2 { margin-top: 0; }
.disclaimer { color: #fbbf24; font-size: 0.9rem; margin-top: 8px; }
.cheatsheet p { margin: 8px 0; font-size: 0.95rem; }

/* Tables - mobile stacked layout */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  display: block;
  overflow-x: auto;
}

th, td {
  padding: 8px;
  text-align: left;
  border-bottom: 1px solid #1f2937;
  min-width: 100px;
}

th {
  background: #1e293b;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 10;
}

/* Navigation - mobile friendly */
nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

nav a {
  padding: 12px;
  text-decoration: none;
  color: #e2e8f0;
  border-radius: 6px;
  transition: background 0.2s;
  min-height: 44px;
  display: flex;
  align-items: center;
}

nav a:hover {
  background: #1e293b;
}

/* Images */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Button Link Utility Classes - Touch-friendly */
.btn-link {
  display: inline-block;
  padding: 12px 20px;
  text-decoration: none;
  border-radius: 6px;
  font-weight: 600;
  text-align: center;
  min-height: 44px;
  min-width: 44px;
  transition: all 0.2s;
  line-height: 1.4;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
}

.btn-warning {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
}

.btn-secondary {
  background: #64748b;
  color: white;
}

.btn-danger {
  background: #ef4444;
  color: white;
}

/* Mobile-friendly button groups */
.btn-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.btn-group .btn-link,
.btn-group button,
.btn-group a {
  width: 100%;
  margin: 0;
}

/* Accessibility - reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== TABLET (640px+) ===== */
@media (min-width: 640px) {
  .wrap {
    padding: 16px;
  }
  
  .card {
    padding: 16px;
    margin: 16px 0;
  }
  
  button, .btn {
    width: auto;
    min-width: 120px;
  }
  
  nav {
    flex-direction: row;
    gap: 12px;
  }
  
  /* Button groups horizontal on tablet+ */
  .btn-group {
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .btn-group .btn-link,
  .btn-group button,
  .btn-group a {
    width: auto;
    flex: 0 1 auto;
  }
}

/* ===== TABLET LANDSCAPE (768px+) ===== */
@media (min-width: 768px) {
  .wrap {
    max-width: 768px;
    padding: 20px;
    margin: 20px auto;
  }
  
  .card {
    padding: 20px;
    border-radius: 12px;
  }
  
  h1 {
    margin: 12px 0 20px;
  }
  
  table {
    display: table;
  }
  
  th, td {
    padding: 12px;
  }
}

/* ===== DESKTOP (1024px+) ===== */
@media (min-width: 1024px) {
  .wrap {
    max-width: 900px;
    padding: 24px;
    margin: 30px auto;
  }
  
  .card {
    padding: 24px;
  }
  
  /* Hover effects only on devices that support hover */
  @media (hover: hover) {
    button:hover, .btn:hover {
      background: #16a34a;
      transform: translateY(-2px);
      box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
    }
  }
}

/* ===== LARGE DESKTOP (1280px+) ===== */
@media (min-width: 1280px) {
  .wrap {
    max-width: 1100px;
  }
}
