/* ==============================================================================
   SDN 008 SUNGAI KUNING - CBT TOOLS DESIGN SYSTEM
   Modern Nordic Glassmorphism Theme (Emerald, Slate, Amber)
   ============================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --primary-50: #ecfdf5;
  --primary-100: #d1fae5;
  --primary-200: #a7f3d0;
  --primary-500: #10b981;
  --primary-600: #059669;
  --primary-700: #047857;
  --primary-800: #065f46;
  
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;

  --amber-50: #fffbeb;
  --amber-100: #fef3c7;
  --amber-200: #fde68a;
  --amber-500: #f59e0b;
  --amber-600: #d97706;
  --amber-700: #b45309;

  --rose-50: #fff1f2;
  --rose-100: #ffe4e6;
  --rose-500: #f43f5e;
  --rose-600: #e11d48;

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Outfit', var(--font-sans);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.05);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.05);
}

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

body {
  font-family: var(--font-sans);
  background-color: #f8fafc;
  color: var(--slate-800);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Background Subtle Mesh Gradient */
.bg-mesh {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 380px;
  background: radial-gradient(circle at 15% 10%, rgba(16, 185, 129, 0.12) 0%, transparent 40%),
              radial-gradient(circle at 85% 15%, rgba(245, 158, 11, 0.08) 0%, transparent 40%);
  pointer-events: none;
  z-index: 0;
}

.app-container {
  position: relative;
  z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem 1rem;
}

@media (min-width: 640px) {
  .app-container {
    padding: 2.5rem 1.5rem 4rem 1.5rem;
  }
}

/* Header & Branding */
.navbar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: var(--radius-xl);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
}

@media (min-width: 768px) {
  .navbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-700) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
  flex-shrink: 0;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--slate-900);
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.brand-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--primary-50);
  color: var(--primary-700);
  border: 1px solid var(--primary-200);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.badge-subdomain {
  font-family: monospace;
  font-size: 0.75rem;
  background: var(--slate-100);
  color: var(--slate-700);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--slate-200);
}

/* Card Style */
.nordic-card {
  background: white;
  border-radius: var(--radius-xl);
  border: 1px solid var(--slate-200);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  transition: all 0.2s ease;
}

@media (min-width: 640px) {
  .nordic-card {
    padding: 2rem;
  }
}

/* Tab Navigation */
.tab-container {
  display: flex;
  background: var(--slate-100);
  padding: 0.35rem;
  border-radius: var(--radius-lg);
  gap: 0.35rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--slate-200);
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--slate-600);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: var(--slate-900);
}

.tab-btn.active {
  background: white;
  color: var(--primary-700);
  box-shadow: var(--shadow-sm);
}

/* Dropzone */
.dropzone {
  border: 2px dashed var(--slate-300);
  border-radius: var(--radius-xl);
  padding: 3rem 1.5rem;
  text-align: center;
  background: var(--slate-50);
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary-500);
  background: var(--primary-50);
  transform: translateY(-2px);
}

.dropzone-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 1rem auto;
  border-radius: var(--radius-lg);
  background: white;
  border: 1px solid var(--slate-200);
  color: var(--primary-600);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.dropzone-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--slate-900);
  margin-bottom: 0.35rem;
}

.dropzone-desc {
  font-size: 0.85rem;
  color: var(--slate-500);
  max-width: 420px;
  margin: 0 auto;
}

/* Paste Mode */
.paste-textarea {
  width: 100%;
  min-height: 220px;
  padding: 1rem;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--slate-300);
  background: white;
  color: var(--slate-800);
  line-height: 1.6;
  resize: vertical;
  transition: all 0.2s ease;
}

.paste-textarea:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

/* Toolbar & Phase Switcher */
.toolbar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.25rem;
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-xl);
  margin-top: 1.5rem;
  box-shadow: var(--shadow-sm);
}

@media (min-width: 768px) {
  .toolbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.phase-switcher {
  display: inline-flex;
  background: var(--slate-100);
  padding: 0.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--slate-200);
}

.phase-btn {
  padding: 0.45rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--slate-600);
  cursor: pointer;
  transition: all 0.15s ease;
}

.phase-btn.active {
  background: var(--primary-600);
  color: white;
  box-shadow: 0 2px 4px rgba(5, 150, 105, 0.25);
}

.stats-badges {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
}

.stat-pill.total {
  background: var(--slate-100);
  color: var(--slate-800);
}

.stat-pill.success {
  background: var(--primary-50);
  color: var(--primary-700);
  border: 1px solid var(--primary-200);
}

.stat-pill.warning {
  background: var(--amber-50);
  color: var(--amber-700);
  border: 1px solid var(--amber-200);
}

/* Primary Action Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 700;
  padding: 0.7rem 1.25rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary-600);
  color: white;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
}

.btn-primary:hover {
  background: var(--primary-700);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(5, 150, 105, 0.3);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: var(--slate-100);
  color: var(--slate-700);
  border: 1px solid var(--slate-200);
}

.btn-secondary:hover {
  background: var(--slate-200);
  color: var(--slate-900);
}

.btn-danger {
  background: var(--rose-50);
  color: var(--rose-600);
  border: 1px solid var(--rose-200);
}

.btn-danger:hover {
  background: var(--rose-100);
}

/* Interactive Review Table */
.review-section {
  margin-top: 1.5rem;
}

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-xl);
  border: 1px solid var(--slate-200);
  background: white;
  box-shadow: var(--shadow-sm);
}

.review-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.review-table th {
  background: var(--slate-50);
  color: var(--slate-700);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--slate-200);
  white-space: nowrap;
}

.review-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--slate-200);
  vertical-align: top;
}

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

.review-table tr.row-warning {
  background: rgba(254, 243, 199, 0.2);
}

.inline-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--slate-200);
  background: white;
  color: var(--slate-800);
  transition: all 0.15s ease;
}

.inline-input:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.15);
}

.inline-textarea {
  min-height: 70px;
  resize: vertical;
}

/* Key Selection Pills */
.key-selector {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.key-pill {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 800;
  border: 1px solid var(--slate-200);
  background: white;
  color: var(--slate-600);
  cursor: pointer;
  transition: all 0.15s ease;
}

.key-pill:hover {
  border-color: var(--primary-500);
  color: var(--primary-600);
}

.key-pill.active {
  background: var(--primary-600);
  color: white;
  border-color: var(--primary-600);
  box-shadow: 0 2px 4px rgba(5, 150, 105, 0.25);
}

/* Badges */
.badge-warning {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--amber-50);
  color: var(--amber-700);
  border: 1px solid var(--amber-200);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-weight: 700;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 9999;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  background: var(--slate-900);
  color: white;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow-xl);
  animation: slideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.success {
  background: var(--primary-800);
  border-left: 4px solid var(--primary-500);
}

.toast.error {
  background: #881337;
  border-left: 4px solid var(--rose-500);
}

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

/* ==============================================================================
   MOBILE-FRIENDLY & RESPONSIVE TOUCH TARGET ENHANCEMENTS
   Audited against Google Mobile-Friendly & Web Accessibility Guidelines
   ============================================================================== */

.mobile-scroll-hint {
  display: none;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary-700);
  background: var(--primary-50);
  border: 1px dashed var(--primary-200);
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.65rem;
  align-items: center;
  gap: 0.35rem;
}

@media (max-width: 768px) {
  .mobile-scroll-hint {
    display: flex;
  }

  /* 1. Prevent iOS Safari auto-zoom on input focus */
  .inline-input,
  .inline-textarea,
  .paste-textarea,
  input,
  textarea {
    font-size: 16px !important;
  }

  /* 2. Enhanced Touch Targets (>= 40px - 48px) */
  .key-pill {
    width: 38px;
    height: 38px;
    font-size: 0.85rem;
    font-weight: 800;
    margin: 0 2px;
  }

  .key-selector {
    gap: 0.35rem;
  }

  .tab-btn {
    min-height: 48px;
    font-size: 0.85rem;
    padding: 0.65rem 0.5rem;
  }

  .phase-btn {
    min-height: 44px;
    padding: 0.6rem 0.85rem;
    font-size: 0.8rem;
  }

  .btn {
    min-height: 46px;
    padding: 0.75rem 1.15rem;
  }

  button[data-action="delete"] {
    min-width: 38px;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* 3. Sticky First Column on Mobile Table */
  .table-wrapper {
    -webkit-overflow-scrolling: touch;
    position: relative;
  }

  .review-table th:first-child,
  .review-table td:first-child {
    position: sticky;
    left: 0;
    background: white;
    z-index: 2;
    box-shadow: 2px 0 6px rgba(0, 0, 0, 0.06);
  }

  .review-table th:first-child {
    background: var(--slate-50);
  }

  /* 4. Safe Area Insets for Modern Mobile Devices */
  .app-container {
    padding-bottom: max(2.5rem, calc(env(safe-area-inset-bottom) + 1.5rem));
  }

  .toast-container {
    bottom: max(1rem, env(safe-area-inset-bottom));
    right: 1rem;
    left: 1rem;
  }
}
