/* BKRRM — main.css
   Google-level Design System Implementation
   Following Material Design 3 principles with Malaysian theme
*/

/* ══════════════════════════════════════════════════════
   DESIGN TOKENS & CUSTOM PROPERTIES
   ══════════════════════════════════════════════════════ */
:root {
  /* Spacing Scale (8px base) */
  --space-1: 0.25rem;  /* 4px */
  --space-2: 0.5rem;   /* 8px */
  --space-3: 0.75rem;  /* 12px */
  --space-4: 1rem;     /* 16px */
  --space-5: 1.5rem;   /* 24px */
  --space-6: 2rem;     /* 32px */
  --space-8: 3rem;     /* 48px */
  --space-12: 6rem;    /* 96px */

  /* Border Radius Scale */
  --radius-sm: 0.5rem;   /* 8px */
  --radius-md: 0.75rem;  /* 12px */
  --radius-lg: 1rem;     /* 16px */
  --radius-xl: 1.5rem;   /* 24px */
  --radius-2xl: 2rem;    /* 32px */

  /* Shadow Scale */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);

  /* Transition Timing */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ══════════════════════════════════════════════════════
   GLOBAL RESETS & BASE STYLES
   ══════════════════════════════════════════════════════ */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', 'Noto Sans SC', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: #1A1A2E;
}

/* Improved focus styles for accessibility */
:focus-visible {
  outline: 3px solid #CC0001;
  outline-offset: 3px;
  border-radius: var(--radius-md);
}

/* Remove focus outline for mouse users */
:focus:not(:focus-visible) {
  outline: none;
}

/* ══════════════════════════════════════════════════════
   FORM COMPONENTS - Enhanced Design System
   ══════════════════════════════════════════════════════ */
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #1A1A2E;
  margin-bottom: 0.5rem;
  letter-spacing: -0.01em;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  border-radius: var(--radius-lg);
  border: 2px solid #E5E7EB;
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
  font-weight: 500;
  color: #1A1A2E;
  background: #fff;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-sm);
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
  border-color: #D1D5DB;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: #CC0001;
  box-shadow: 0 0 0 4px rgba(204, 0, 1, 0.12);
  transform: translateY(-1px);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236B7280' stroke-width='2.5'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1.25rem;
  padding-right: 2.75rem;
}

.form-textarea {
  resize: vertical;
  min-height: 120px;
}

.form-hint {
  font-size: 0.8125rem;
  color: #6B7280;
  margin-top: 0.375rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.form-error {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #DC2626;
  margin-top: 0.375rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

/* Input error state */
.form-input.error,
.form-select.error,
.form-textarea.error {
  border-color: #DC2626;
  background-color: #FEF2F2;
}

.form-input.error:focus,
.form-select.error:focus,
.form-textarea.error:focus {
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.12);
}

/* ══════════════════════════════════════════════════════
   NAVIGATION COMPONENTS
   ══════════════════════════════════════════════════════ */
.nav-link {
  position: relative;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
  transition: all var(--transition-base);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: 0.25rem;
  left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 80%;
  height: 2px;
  background: linear-gradient(90deg, #CC0001, #990001);
  border-radius: 2px;
  transition: transform var(--transition-smooth);
}

.nav-link:hover {
  color: #003F87;
  background: linear-gradient(135deg, #E8F4FD 0%, #F0F9FF 100%);
}

.nav-link:hover::after {
  transform: translateX(-50%) scaleX(1);
}

.nav-link-active {
  color: #CC0001;
  background: linear-gradient(135deg, rgba(204, 0, 1, 0.08) 0%, rgba(204, 0, 1, 0.04) 100%);
  font-weight: 600;
}

.nav-link-active::after {
  transform: translateX(-50%) scaleX(1);
}

.mobile-nav-link {
  display: block;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-xl);
  font-size: 0.9375rem;
  font-weight: 500;
  color: #374151;
  transition: all var(--transition-base);
  border: 2px solid transparent;
}

.mobile-nav-link:hover {
  background: linear-gradient(135deg, #F3F4F6 0%, #F9FAFB 100%);
  color: #003F87;
  border-color: #E5E7EB;
  transform: translateX(4px);
}

.mobile-nav-link:active {
  transform: translateX(2px) scale(0.98);
}

/* ══════════════════════════════════════════════════════
   FOOTER COMPONENTS
   ══════════════════════════════════════════════════════ */
.footer-link {
  font-size: 0.875rem;
  font-weight: 500;
  color: #93C5FD;
  transition: all var(--transition-base);
  position: relative;
  display: inline-block;
}

.footer-link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, #fff, #93C5FD);
  transition: width var(--transition-smooth);
}

.footer-link:hover {
  color: #fff;
  transform: translateX(2px);
}

.footer-link:hover::after {
  width: 100%;
}

/* ══════════════════════════════════════════════════════
   UTILITY CLASSES
   ══════════════════════════════════════════════════════ */

/* Step panel visibility for multi-step forms */
.step-panel {
  display: none;
  animation: fadeInUp var(--transition-smooth) ease-out;
}

.step-panel.active {
  display: block;
}

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

/* Alert components with improved animation */
.alert-item {
  animation: slideInRight var(--transition-smooth) ease-out;
}

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

/* Loading spinner overlay */
.spinner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 9999;
  animation: fadeIn var(--transition-base);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.spinner {
  width: 3rem;
  height: 3rem;
  border: 4px solid #E5E7EB;
  border-top-color: #CC0001;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Scroll progress indicator */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 3px;
  background: linear-gradient(90deg, #CC0001, #FFD700);
  z-index: 9999;
  transition: width 0.2s ease-out;
}

/* Accessibility - Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.sr-only-focusable:focus,
.sr-only-focusable:active {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* ══════════════════════════════════════════════════════
   PRINT STYLES
   ══════════════════════════════════════════════════════ */
@media print {
  nav,
  footer,
  .no-print,
  .alert-item {
    display: none !important;
  }

  body {
    color: #000;
    background: #fff;
  }

  a[href]:after {
    content: " (" attr(href) ")";
  }
}

/* ══════════════════════════════════════════════════════
   RESPONSIVE UTILITIES
   ══════════════════════════════════════════════════════ */
@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;
  }
}

/* Dark mode support (future enhancement) */
@media (prefers-color-scheme: dark) {
  /* Prepared for future dark mode implementation */
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .form-input,
  .form-select,
  .form-textarea {
    border-width: 3px;
  }

  .nav-link,
  .mobile-nav-link {
    border-width: 2px;
  }
}


