/* ================================
   PRIME BOOST - Global Styles
   ================================ */

/* CSS Variables */
:root {
  --sky: #2563eb;
  --dark-sky: #1e40af;
  --white: #ffffff;
  --off-white: #f6f7f9;
  --light-blue: #eef1f8;
  --border: #d8dce6;
  --muted: #5a6a82;
  --success: #33b843;
  --warning: #f59e0b;
  --error: #c4202c;
  --info: #3b82f6;
  --primary-blue: #1e3a8a;
  --navy: #1e3a8a;

  --bg-primary: #ffffff;
  --bg-secondary: #f6f7f9;
  --bg-tertiary: #eef1f8;
  --text-primary: #1e293b;
  --text-secondary: #5a6a82;
  --border-color: #d8dce6;
  --sidebar-bg: #2563eb;
  --card-bg: #ffffff;
  --input-bg: #ffffff;
  --hover-bg: #f6f7f9;

  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;

  --section-pad-y: clamp(60px, 8vw, 160px);
  --section-pad-x: clamp(20px, 5vw, 80px);
  --content-max-w: 1400px;
  --grid-gap: clamp(16px, 2vw, 32px);
  --card-pad: 24px;
  --card-radius: 12px;
  --btn-radius: 8px;
  --input-height: 48px;
  --sidebar-w: 250px;
  --sidebar-collapsed-w: 64px;
  --header-h: 64px;

  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Dark Theme */
[data-theme="dark"] {
  --bg-primary: #0c1525;
  --bg-secondary: #111d35;
  --bg-tertiary: #162544;
  --text-primary: #f0f2f5;
  --text-secondary: #8a9bb5;
  --border-color: #1e4a8a;
  --sidebar-bg: #1e40af;
  --card-bg: #111d35;
  --navy: #1e40af;
  --input-bg: #162544;
  --hover-bg: #1a3050;
}

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

html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html {
  font-size: 16px;
}

body {
  font-family: var(--font-main);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
}

/* Images never overflow their container */
img, svg, video, canvas, iframe {
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
}

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

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  outline: none;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* ================================
   UTILITY CLASSES
   ================================ */
.container {
  max-width: var(--content-max-w);
  margin: 0 auto;
  padding: 0 var(--section-pad-x);
}

.section {
  padding: var(--section-pad-y) 0;
}

.section-title {
  font-size: clamp(28px, 3vw, 48px);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.section-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 16px;
  display: block;
}

/* Reveal Animation */
.reveal {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.8s var(--ease-out-expo), transform 0.8s var(--ease-out-expo);
}
.reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}
.reveal-delay-1 { transition-delay: 0.08s; }
.reveal-delay-2 { transition-delay: 0.16s; }
.reveal-delay-3 { transition-delay: 0.24s; }
.reveal-delay-4 { transition-delay: 0.32s; }
.reveal-delay-5 { transition-delay: 0.40s; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 32px;
  border-radius: var(--btn-radius);
  font-size: 15px;
  font-weight: 600;
  transition: all 0.2s ease;
  cursor: pointer;
  white-space: nowrap;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--sky);
  color: #fff;
  border: none;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-blue);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(10,22,40,0.25);
}

.btn-outline {
  background: transparent;
  color: var(--sky);
  border: 1.5px solid var(--sky);
}
[data-theme="dark"] .btn-outline {
  color: var(--text-primary);
  border-color: var(--border-color);
}
.btn-outline:hover:not(:disabled) {
  background: var(--sky);
  color: #fff;
}

.btn-white {
  background: #fff;
  color: var(--sky);
  border: none;
}
.btn-white:hover:not(:disabled) {
  background: var(--off-white);
  transform: translateY(-1px);
}

.btn-outline-white {
  background: transparent;
  color: #fff;
  border: 1.5px solid rgba(255,255,255,0.3);
}
.btn-outline-white:hover:not(:disabled) {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.5);
}

.btn-danger {
  background: var(--error);
  color: #fff;
}
.btn-danger:hover:not(:disabled) {
  background: #a31c24;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
}

.btn-lg {
  padding: 18px 40px;
  font-size: 16px;
}

/* Form Inputs */
.form-group {
  margin-bottom: 20px;
}
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-input {
  width: 100%;
  height: var(--input-height);
  padding: 0 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--btn-radius);
  font-size: 16px;
  color: var(--text-primary);
  background: var(--input-bg);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.form-input:focus {
  border-color: var(--sky);
  box-shadow: 0 0 0 3px rgba(10,22,40,0.08);
}
.form-input::placeholder {
  color: var(--muted);
}
.form-input.error {
  border-color: var(--error);
}
.error-text {
  color: var(--error);
  font-size: 13px;
  margin-top: 4px;
}

.input-wrapper {
  position: relative;
}
.password-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
}
.password-toggle:hover {
  color: var(--text-primary);
}

/* Card */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--card-radius);
  padding: var(--card-pad);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.card-hover:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(10,22,40,0.08);
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-error { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-processing { background: #dbeafe; color: #1e40af; }
.badge-completed { background: #d1fae5; color: #065f46; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }
.badge-partial { background: #fed7aa; color: #9a3412; }

/* Toggle Switch */
.toggle-switch {
  width: 48px;
  height: 26px;
  background: var(--border-color);
  border-radius: 13px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease;
  flex-shrink: 0;
}
.toggle-switch.on {
  background: var(--sky);
}
.toggle-switch .slider {
  width: 22px;
  height: 22px;
  background: #fff;
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch.on .slider {
  transform: translateX(22px);
}

/* Toast */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 14px 24px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  animation: slideInRight 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
  max-width: 400px;
}
.toast-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.toast-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.toast-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

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

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
  padding: 20px;
}
.modal-content {
  background: var(--bg-primary);
  border-radius: 16px;
  padding: 36px;
  max-width: 500px;
  width: 100%;
  animation: scaleIn 0.2s ease;
}
.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  justify-content: flex-end;
}

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

/* Loading Spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--sky);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ================================
   RESPONSIVE
   ================================ */

/* All inputs must be 16px minimum to prevent iOS zoom */
input, select, textarea, .form-input {
  font-size: 16px !important;
}
input[type="text"], input[type="email"], input[type="password"], input[type="number"] {
  font-size: 16px !important;
}

@media (max-width: 1023px) {
  :root {
    --section-pad-y: clamp(40px, 6vw, 80px);
  }
  .container {
    padding: 0 20px;
  }
  .section {
    padding: 60px 0;
  }
  .section-title {
    font-size: clamp(24px, 4vw, 36px);
  }
  .modal-content {
    padding: 28px;
    margin: 20px;
  }
}

@media (max-width: 767px) {
  :root {
    --section-pad-x: 16px;
    --card-pad: 16px;
    --header-h: 56px;
  }
  html {
    font-size: 15px;
  }
  .container {
    padding: 0 16px;
  }
  .section {
    padding: 48px 0;
  }
  .section-title {
    font-size: 24px;
    line-height: 1.3;
  }
  .section-label {
    font-size: 11px;
  }
  .btn {
    padding: 12px 24px;
    font-size: 14px;
  }
  .btn-lg {
    padding: 14px 28px;
    font-size: 15px;
  }
  .btn-sm {
    padding: 8px 14px;
    font-size: 12px;
  }
  .card {
    padding: 16px;
    border-radius: 10px;
  }
  .form-group {
    margin-bottom: 16px;
  }
  .form-input {
    height: 48px;
    font-size: 16px !important;
    padding: 0 14px;
  }
  .form-label {
    font-size: 12px;
  }
  .toast-container {
    left: 12px;
    right: 12px;
    top: 12px;
  }
  .toast {
    max-width: 100%;
    font-size: 13px;
    padding: 12px 16px;
  }
  .modal-overlay {
    padding: 12px;
  }
  .modal-content {
    padding: 24px 20px;
    margin: 0;
    max-width: 100%;
    border-radius: 12px;
  }
  .modal-actions {
    flex-direction: column;
    gap: 8px;
  }
  .modal-actions .btn {
    width: 100%;
  }
  .spinner {
    width: 16px;
    height: 16px;
  }
}

@media (max-width: 479px) {
  html {
    font-size: 14px;
  }
  .container {
    padding: 0 12px;
  }
  .section {
    padding: 36px 0;
  }
  .section-title {
    font-size: 22px;
  }
  .btn {
    padding: 12px 20px;
    font-size: 13px;
  }
  .form-input {
    height: 44px;
    font-size: 16px !important;
  }
}
