/* ============================================================
   RadarTrade - Global Stylesheet
   Design System: Blue-based financial UI
   Font: Inter (Google Fonts)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* -------------------------------------------------------
   1. CSS Reset
   ------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

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

ul,
ol {
  list-style: none;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* -------------------------------------------------------
   2. CSS Custom Properties (Design Tokens)
   ------------------------------------------------------- */
:root {
  /* Blue palette */
  --blue-900: #0f172a;
  --blue-700: #1d4ed8;
  --blue-600: #2563eb;
  --blue-500: #3b82f6;
  --blue-100: #dbeafe;
  --blue-50: #eff6ff;

  /* Neutrals */
  --white: #ffffff;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-400: #94a3b8;
  --gray-700: #334155;
  --gray-900: #0f172a;

  /* Semantic */
  --green-500: #22c55e;
  --red-500: #ef4444;
  --yellow-500: #eab308;
  --purple-500: #a855f7;

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #1d4ed8 0%, #3b82f6 50%, #06b6d4 100%);

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 2rem;

  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --spacing-2xl: 48px;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 2px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.12);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.3s ease;

  /* Z-index scale */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-overlay: 300;
  --z-modal: 400;
  --z-toast: 500;
}

/* -------------------------------------------------------
   3. Base Typography
   ------------------------------------------------------- */
body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--gray-900);
  background-color: var(--white);
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.3;
  color: var(--gray-900);
}

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }
h5 { font-size: var(--font-size-base); }
h6 { font-size: var(--font-size-sm); }

p {
  margin-bottom: var(--spacing-md);
  color: var(--gray-700);
  line-height: 1.7;
}

small {
  font-size: var(--font-size-sm);
}

strong {
  font-weight: 600;
}

/* -------------------------------------------------------
   4. Container
   ------------------------------------------------------- */
.container {
  width: 100%;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--spacing-lg);
  padding-right: var(--spacing-lg);
}

@media (max-width: 768px) {
  .container {
    padding-left: var(--spacing-md);
    padding-right: var(--spacing-md);
  }
}

/* -------------------------------------------------------
   5. Buttons
   ------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: var(--font-size-sm);
  font-weight: 600;
  line-height: 1.5;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
  user-select: none;
}

.btn:focus-visible {
  outline: 2px solid var(--blue-500);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Primary - Gradient CTA */
.btn-primary {
  background: var(--gradient-primary);
  color: var(--white);
  padding: 14px 32px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: var(--font-size-base);
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35);
  border: none;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(37, 99, 235, 0.45);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

/* Secondary - Outline */
.btn-secondary {
  background: transparent;
  color: var(--blue-600);
  border: 2px solid var(--blue-600);
  padding: 12px 28px;
  font-weight: 600;
}

.btn-secondary:hover {
  background: var(--blue-50);
  transform: translateY(-2px);
}

.btn-secondary:active {
  transform: translateY(0);
}

/* Outline */
.btn-outline {
  background: transparent;
  color: var(--gray-700);
  border: 2px solid var(--gray-200);
}

.btn-outline:hover {
  border-color: var(--gray-400);
  background: var(--gray-50);
  transform: translateY(-1px);
}

/* Danger */
.btn-danger {
  background: var(--red-500);
  color: var(--white);
  border: none;
}

.btn-danger:hover {
  background: #dc2626;
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.35);
}

/* Small */
.btn-sm {
  padding: 6px 14px;
  font-size: var(--font-size-xs);
  border-radius: 6px;
}

/* -------------------------------------------------------
   6. Cards
   ------------------------------------------------------- */
.card {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--gray-100);
  padding: var(--spacing-lg);
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

/* -------------------------------------------------------
   7. Badges
   ------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  line-height: 1.5;
  white-space: nowrap;
}

.badge-primary {
  background: var(--blue-100);
  color: var(--blue-700);
}

.badge-success {
  background: #dcfce7;
  color: #16a34a;
}

.badge-danger {
  background: #fee2e2;
  color: #dc2626;
}

.badge-warning {
  background: #fef9c3;
  color: #a16207;
}

.badge-purple {
  background: #f3e8ff;
  color: #7c3aed;
}

.badge-neutral {
  background: var(--gray-100);
  color: var(--gray-700);
}

/* -------------------------------------------------------
   8. Form Elements
   ------------------------------------------------------- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--spacing-md);
}

.form-group label {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--gray-700);
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 10px 14px;
  font-size: var(--font-size-sm);
  color: var(--gray-900);
  background: var(--white);
  border: 1.5px solid #e2e8f0;
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--gray-400);
}

.input:disabled,
.select:disabled,
.textarea:disabled {
  background: var(--gray-50);
  color: var(--gray-400);
  cursor: not-allowed;
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

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

.input-error {
  border-color: var(--red-500) !important;
}

.input-error:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
}

.form-error {
  font-size: var(--font-size-xs);
  color: var(--red-500);
  margin-top: 2px;
}

/* -------------------------------------------------------
   9. Toasts
   ------------------------------------------------------- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  min-width: 320px;
  max-width: 440px;
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  background: var(--white);
  box-shadow: var(--shadow-xl);
  border-left: 4px solid var(--gray-400);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--gray-900);
  z-index: var(--z-toast);
  animation: slideInRight 0.35s ease forwards;
  transform: translateX(120%);
}

.toast-success {
  border-left-color: var(--green-500);
}

.toast-success::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green-500);
  flex-shrink: 0;
}

.toast-error {
  border-left-color: var(--red-500);
}

.toast-error::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red-500);
  flex-shrink: 0;
}

.toast-warning {
  border-left-color: var(--yellow-500);
}

.toast-warning::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--yellow-500);
  flex-shrink: 0;
}

.toast-close {
  margin-left: auto;
  padding: 4px;
  color: var(--gray-400);
  cursor: pointer;
  transition: color var(--transition-fast);
  flex-shrink: 0;
}

.toast-close:hover {
  color: var(--gray-700);
}

/* -------------------------------------------------------
   10. Modal
   ------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: var(--spacing-md);
  animation: fadeIn 0.2s ease;
}
.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-100);
}

.modal-header h2,
.modal-header h3 {
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin: 0;
}

.modal-header .modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--gray-400);
  transition: all var(--transition-fast);
}

.modal-header .modal-close:hover {
  background: var(--gray-100);
  color: var(--gray-700);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--gray-100);
}

/* -------------------------------------------------------
   11. Tables
   ------------------------------------------------------- */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.table th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-400);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-100);
  white-space: nowrap;
}

.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  vertical-align: middle;
}

.table tbody tr {
  transition: background var(--transition-fast);
}

.table tbody tr:hover {
  background: var(--gray-50);
}

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

/* -------------------------------------------------------
   12. Text Color Utilities
   ------------------------------------------------------- */
.text-red {
  color: var(--red-500) !important;
}

.text-green {
  color: var(--green-500) !important;
}

.text-yellow {
  color: var(--yellow-500) !important;
}

.text-blue {
  color: var(--blue-500) !important;
}

.text-purple {
  color: var(--purple-500) !important;
}

.text-gray {
  color: var(--gray-400) !important;
}

.text-white {
  color: var(--white) !important;
}

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

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

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

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

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* -------------------------------------------------------
   14. Animation Utility Classes
   ------------------------------------------------------- */
.animate-fade-in {
  animation: fadeIn 0.4s ease forwards;
}

.animate-slide-up {
  animation: slideUp 0.4s ease forwards;
}

.animate-slide-in-right {
  animation: slideInRight 0.35s ease forwards;
}

.animate-spin {
  animation: spin 0.8s linear infinite;
}

.animate-pulse {
  animation: pulse 2s ease-in-out infinite;
}

/* -------------------------------------------------------
   15. General Utilities
   ------------------------------------------------------- */
.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;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.justify-center {
  justify-content: center;
}

.gap-sm {
  gap: var(--spacing-sm);
}

.gap-md {
  gap: var(--spacing-md);
}

.gap-lg {
  gap: var(--spacing-lg);
}

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

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

.font-bold {
  font-weight: 700;
}

.font-semibold {
  font-weight: 600;
}

.w-full {
  width: 100%;
}

.hidden {
  display: none !important;
}

/* -------------------------------------------------------
   16. Scrollbar
   ------------------------------------------------------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--gray-200);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gray-400);
}

/* -------------------------------------------------------
   17. Responsive Breakpoints
   ------------------------------------------------------- */

/* Tablet: 768px - 1024px */
@media (min-width: 768px) and (max-width: 1024px) {
  html {
    font-size: 15px;
  }

  .container {
    max-width: 720px;
  }

  .modal {
    max-width: 480px;
  }
}

/* Mobile: < 768px */
@media (max-width: 767px) {
  html {
    font-size: 14px;
  }

  .container {
    padding-left: var(--spacing-md);
    padding-right: var(--spacing-md);
  }

  h1 { font-size: var(--font-size-2xl); }
  h2 { font-size: var(--font-size-xl); }
  h3 { font-size: var(--font-size-lg); }

  .btn-primary {
    padding: 12px 24px;
    font-size: var(--font-size-sm);
    width: 100%;
  }

  .btn-secondary {
    padding: 10px 20px;
    width: 100%;
  }

  .card {
    padding: var(--spacing-md);
    border-radius: var(--radius-lg);
  }

  .modal {
    max-width: 100%;
    margin: var(--spacing-md);
    max-height: 85vh;
  }

  .modal-header {
    padding: 16px 20px;
  }

  .modal-body {
    padding: 20px;
  }

  .modal-footer {
    padding: 12px 20px;
    flex-direction: column;
  }

  .modal-footer .btn {
    width: 100%;
  }

  .toast {
    left: 16px;
    right: 16px;
    bottom: 16px;
    min-width: auto;
  }

  .table {
    font-size: var(--font-size-xs);
  }

  .table th,
  .table td {
    padding: 8px 12px;
  }
}
