/* ============================================================================
   Falcon AI - Enhanced Design System v2.0
   Professional, Accessible, and Modern UI
   ============================================================================ */

/* ============================================================================
   1. DESIGN SYSTEM VARIABLES
   ============================================================================ */

:root {
  /* ─────────────────────────────────────────────────────────────────────
     Color System
     ───────────────────────────────────────────────────────────────────── */
  
  /* Primary Green - الأساسي */
  --primary-900: #051c16;
  --primary-800: #0d3325;
  --primary-700: #153f31;
  --primary-600: #18543e;
  --primary-500: #1e7a5b;
  --primary-400: #2d9667;
  --primary-300: #4db386;
  --primary-200: #a3d9c1;
  --primary-100: #e8f5f0;
  --primary-50: #f5faf8;

  /* Semantic Colors */
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --error: #ef4444;
  --error-light: #fee2e2;
  --info: #3b82f6;
  --info-light: #dbeafe;

  /* Neutral Grays */
  --neutral-900: #111827;
  --neutral-800: #1f2937;
  --neutral-700: #374151;
  --neutral-600: #4b5563;
  --neutral-500: #6b7280;
  --neutral-400: #9ca3af;
  --neutral-300: #d1d5db;
  --neutral-200: #e5e7eb;
  --neutral-100: #f3f4f6;
  --neutral-50: #f9fafb;

  /* Backgrounds */
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --bg-tertiary: #f3f4f6;
  --bg-overlay: rgba(11, 26, 18, 0.45);

  /* ─────────────────────────────────────────────────────────────────────
     Shadows (Elevation System)
     ───────────────────────────────────────────────────────────────────── */
  
  --shadow-none: none;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 10px 32px rgba(11, 39, 28, 0.09);
  --shadow-xl: 0 20px 50px rgba(0, 0, 0, 0.15);
  --shadow-2xl: 0 30px 80px rgba(0, 0, 0, 0.25);

  /* ─────────────────────────────────────────────────────────────────────
     Typography
     ───────────────────────────────────────────────────────────────────── */
  
  --font-family-base: "IBM Plex Sans Arabic", -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, Arial, sans-serif;
  --font-family-mono: "IBM Plex Mono", "Monaco", "Menlo", monospace;

  --text-h1-size: 32px;
  --text-h1-weight: 800;
  --text-h1-line: 1.2;

  --text-h2-size: 24px;
  --text-h2-weight: 700;
  --text-h2-line: 1.3;

  --text-h3-size: 20px;
  --text-h3-weight: 700;
  --text-h3-line: 1.4;

  --text-body-lg-size: 16px;
  --text-body-lg-weight: 400;
  --text-body-lg-line: 1.6;

  --text-body-md-size: 14px;
  --text-body-md-weight: 400;
  --text-body-md-line: 1.6;

  --text-label-size: 12px;
  --text-label-weight: 600;
  --text-label-line: 1.5;

  --text-caption-size: 11px;
  --text-caption-weight: 500;
  --text-caption-line: 1.4;

  /* ─────────────────────────────────────────────────────────────────────
     Spacing Scale
     ───────────────────────────────────────────────────────────────────── */
  
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --space-16: 64px;

  /* ─────────────────────────────────────────────────────────────────────
     Border Radius
     ───────────────────────────────────────────────────────────────────── */
  
  --radius-none: 0;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* ─────────────────────────────────────────────────────────────────────
     Transitions & Animations
     ───────────────────────────────────────────────────────────────────── */
  
  --duration-fastest: 50ms;
  --duration-fast: 100ms;
  --duration-base: 200ms;
  --duration-slow: 300ms;
  --duration-slower: 500ms;

  --ease-linear: linear;
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-out-cubic: cubic-bezier(0.215, 0.61, 0.355, 1);
  --ease-in-cubic: cubic-bezier(0.55, 0.055, 0.675, 0.19);

  /* ─────────────────────────────────────────────────────────────────────
     Z-Index Scale
     ───────────────────────────────────────────────────────────────────── */
  
  --z-hide: -1;
  --z-base: 0;
  --z-dropdown: 1000;
  --z-sticky: 10;
  --z-fixed: 20;
  --z-modal-backdrop: 80;
  --z-modal: 81;
  --z-tooltip: 90;
  --z-notification: 100;
}

/* ============================================================================
   2. GLOBAL STYLES
   ============================================================================ */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-secondary);
  color: var(--neutral-900);
  font-family: var(--font-family-base);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.6;
}

body {
  min-height: 100vh;
}

/* ============================================================================
   3. TYPOGRAPHY STYLES
   ============================================================================ */

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

h1 {
  font-size: var(--text-h1-size);
  font-weight: var(--text-h1-weight);
  line-height: var(--text-h1-line);
  letter-spacing: 0.2px;
}

h2 {
  font-size: var(--text-h2-size);
  font-weight: var(--text-h2-weight);
  line-height: var(--text-h2-line);
  letter-spacing: 0.1px;
}

h3 {
  font-size: var(--text-h3-size);
  font-weight: var(--text-h3-weight);
  line-height: var(--text-h3-line);
}

p {
  margin: 0 0 var(--space-3) 0;
}

p:last-child {
  margin-bottom: 0;
}

label {
  display: block;
  font-size: var(--text-label-size);
  font-weight: var(--text-label-weight);
  color: var(--neutral-600);
  margin-bottom: var(--space-2);
  text-transform: none;
}

small {
  font-size: var(--text-caption-size);
  color: var(--neutral-500);
}

/* ============================================================================
   4. BUTTON COMPONENT SYSTEM
   ============================================================================ */

button,
[role="button"],
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  min-height: 40px;
  font-family: inherit;
  font-size: var(--text-body-md-size);
  font-weight: 600;
  line-height: 1;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-base) var(--ease-in-out);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

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

/* ─────────────────────────────────────────────────────────────────────
   Button Variants
   ───────────────────────────────────────────────────────────────────── */

/* Primary Button */
.btn-primary,
button.primary {
  background-color: var(--primary-600);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled),
button.primary:hover:not(:disabled) {
  background-color: var(--primary-700);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.btn-primary:active:not(:disabled),
button.primary:active:not(:disabled) {
  background-color: var(--primary-800);
  transform: translateY(0);
}

.btn-primary:focus-visible,
button.primary:focus-visible {
  outline: 2px solid var(--primary-300);
  outline-offset: 2px;
}

/* Secondary Button */
.btn-secondary,
button.secondary {
  background-color: white;
  color: var(--neutral-900);
  border: 1px solid var(--neutral-200);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover:not(:disabled),
button.secondary:hover:not(:disabled) {
  background-color: var(--neutral-50);
  border-color: var(--neutral-300);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:active:not(:disabled),
button.secondary:active:not(:disabled) {
  background-color: var(--neutral-100);
}

/* Tertiary Button */
.btn-tertiary {
  background-color: transparent;
  color: var(--primary-600);
  border: none;
}

.btn-tertiary:hover:not(:disabled) {
  background-color: var(--primary-50);
  color: var(--primary-700);
}

.btn-tertiary:active:not(:disabled) {
  background-color: var(--primary-100);
}

/* Danger Button */
.btn-danger {
  background-color: var(--error);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-danger:hover:not(:disabled) {
  background-color: #dc2626;
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* Success Button */
.btn-success {
  background-color: var(--success);
  color: white;
}

.btn-success:hover:not(:disabled) {
  background-color: #059669;
  box-shadow: var(--shadow-md);
}

/* ─────────────────────────────────────────────────────────────────────
   Button Sizes
   ───────────────────────────────────────────────────────────────────── */

.btn-sm {
  padding: var(--space-2) var(--space-3);
  min-height: 32px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: var(--space-4) var(--space-6);
  min-height: 48px;
  font-size: 16px;
  border-radius: var(--radius-lg);
}

/* ============================================================================
   5. FORM COMPONENT STYLES
   ============================================================================ */

input,
select,
textarea {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-family: inherit;
  font-size: 16px;
  color: var(--neutral-900);
  background-color: white;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-md);
  transition: all var(--duration-base) var(--ease-in-out);
  -webkit-appearance: none;
  appearance: none;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px var(--primary-100);
  background-color: white;
}

input:disabled,
select:disabled,
textarea:disabled {
  background-color: var(--neutral-50);
  color: var(--neutral-500);
  cursor: not-allowed;
  opacity: 0.6;
}

input::placeholder {
  color: var(--neutral-400);
}

/* Error State */
input.error,
select.error,
textarea.error {
  border-color: var(--error);
  background-color: #fff5f5;
}

input.error:focus,
select.error:focus,
textarea.error:focus {
  box-shadow: 0 0 0 3px var(--error-light);
  border-color: var(--error);
}

/* Success State */
input.success,
select.success,
textarea.success {
  border-color: var(--success);
  background-color: #f0fdf4;
}

input.success:focus,
select.success:focus,
textarea.success:focus {
  box-shadow: 0 0 0 3px var(--success-light);
  border-color: var(--success);
}

/* ============================================================================
   6. CARD COMPONENT
   ============================================================================ */

.card {
  background-color: white;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: all var(--duration-base) var(--ease-in-out);
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--neutral-300);
}

.card-elevated {
  box-shadow: var(--shadow-md);
}

.card-interactive {
  cursor: pointer;
  user-select: none;
}

.card-interactive:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-300);
}

.card-interactive:active {
  transform: translateY(-2px);
}

.card-header {
  padding: var(--space-4);
  border-bottom: 1px solid var(--neutral-100);
}

.card-body {
  padding: var(--space-4);
}

.card-footer {
  padding: var(--space-4);
  border-top: 1px solid var(--neutral-100);
  background-color: var(--neutral-50);
}

/* ============================================================================
   7. GRID & LAYOUT SYSTEM
   ============================================================================ */

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.col-span-2 {
  grid-column: span 2;
}

.col-span-3 {
  grid-column: span 3;
}

.col-span-4 {
  grid-column: span 4;
}

.flex {
  display: flex;
}

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

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.flex-center {
  display: flex;
  justify-content: center;
  align-items: center;
}

.gap-2 {
  gap: var(--space-2);
}

.gap-3 {
  gap: var(--space-3);
}

.gap-4 {
  gap: var(--space-4);
}

/* ============================================================================
   8. UTILITY CLASSES
   ============================================================================ */

/* Padding */
.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.py-4 { padding-top: var(--space-4); padding-bottom: var(--space-4); }

/* Margin */
.m-0 { margin: 0; }
.my-2 { margin-top: var(--space-2); margin-bottom: var(--space-2); }
.my-4 { margin-top: var(--space-4); margin-bottom: var(--space-4); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mt-4 { margin-top: var(--space-4); }

/* Text Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.text-muted { color: var(--neutral-500); }
.text-error { color: var(--error); }
.text-success { color: var(--success); }
.text-sm { font-size: var(--text-body-md-size); }
.text-xs { font-size: var(--text-label-size); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }

/* Display Utilities */
.hidden { display: none !important; }
.visible { display: block !important; }
.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;
}

/* ============================================================================
   9. MICRO-INTERACTIONS & ANIMATIONS
   ============================================================================ */

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

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

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

.animate-fade-in {
  animation: fadeIn var(--duration-base) var(--ease-in-out);
}

.animate-slide-up {
  animation: slideUp var(--duration-base) var(--ease-out);
}

.animate-slide-down {
  animation: slideDown var(--duration-base) var(--ease-out);
}

.animate-pulse {
  animation: pulse var(--duration-slow) var(--ease-linear) infinite;
}

.animate-spin {
  animation: spin 1s var(--ease-linear) infinite;
}

/* ============================================================================
   10. RESPONSIVE DESIGN
   ============================================================================ */

/* Tablets */
@media (min-width: 680px) {
  .grid-2,
  .grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Desktops */
@media (min-width: 1024px) {
  :root {
    font-size: 17px;
  }
}

/* ============================================================================
   11. ACCESSIBILITY
   ============================================================================ */

/* Focus visible for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
}

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

/* High contrast mode support */
@media (prefers-contrast: more) {
  button,
  input,
  select,
  textarea {
    border-width: 2px;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  html,
  body {
    background-color: var(--neutral-900);
    color: var(--neutral-100);
  }

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    color: var(--neutral-100);
  }

  .card {
    background-color: var(--neutral-800);
    border-color: var(--neutral-700);
  }

  input,
  select,
  textarea {
    background-color: var(--neutral-800);
    border-color: var(--neutral-700);
    color: var(--neutral-100);
  }

  input:focus,
  select:focus,
  textarea:focus {
    background-color: var(--neutral-800);
  }

  button.secondary {
    background-color: var(--neutral-800);
    color: var(--neutral-100);
    border-color: var(--neutral-700);
  }
}

/* ============================================================================
   12. PRINT STYLES
   ============================================================================ */

@media print {
  button,
  .btn,
  nav {
    display: none;
  }

  body {
    background-color: white;
    color: black;
  }

  .card {
    page-break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
  }
}
