/* ============================================
   Theme Styles - מאוחד
   תוכנית שידרוג עיצוב Enterprise מקיף
   ============================================
   
   קובץ מאוחד - כל עיצובי התמות
   אוחד מכל קבצי התמות:
   - theme.css (הקודם)
   - theme-system.css
   - theme-selector.css
   - theme-modern.css (חלקים רלוונטיים)
   
   תאריך יצירה: 2025-01-27
   גרסה: 2.0.0 (מאוחד)
   ============================================ */

@layer theme {
  /* ========================================
     Dark Theme - תמה כהה (ברירת מחדל בלבד)
     ======================================== */
  
  :root,
  [data-theme="dark"],
  .dark {
    /* רקעים */
    --bg-page: #1b2330;
    --bg-main: #1b2330;
    --bg-main-alt: #1f2937;
    --bg-surface: #273245;
    --bg-surface-soft: #2e3a4e;
    --bg-elevated: #323f57;
    --bg-muted: #1e293b;
    --bg-overlay: rgba(0, 0, 0, 0.7);

    /* טקסט */
    --text-main: #e9eef5;
    --text-secondary: #b8c2cf;
    --text-muted: #9aa3b4;
    --text-inverse: #ffffff;
    --text-disabled: #475569;
    --text-on-primary: #ffffff;

    /* גבולות */
    --border-subtle: rgba(148, 163, 184, 0.35);
    --border-strong: rgba(148, 163, 184, 0.6);
    --border-soft: rgba(148, 163, 184, 0.2);
    --border-focus: var(--primary-400);
    --border-error: var(--error-400);

    /* צללים */
    --shadow-soft: 0 6px 24px rgba(15, 23, 42, 0.45);
    --shadow-card: 0 4px 18px rgba(15, 23, 42, 0.55);
    --shadow-strong: 0 8px 32px rgba(15, 23, 42, 0.65);

    /* Aliasים */
    --primary-soft: rgba(77, 163, 255, 0.12);
    --primary-soft-strong: rgba(77, 163, 255, 0.18);
    --success-soft: rgba(34, 197, 94, 0.12);
    --warning-soft: rgba(251, 191, 36, 0.12);
    --danger-soft: rgba(239, 68, 68, 0.12);
    --info-soft: rgba(56, 189, 248, 0.12);
  }

  /* ========================================
     High Contrast Theme - תמה ניגודיות גבוהה
     ======================================== */
  
  [data-theme="high-contrast"] {
    /* Primary Colors */
    --primary-50: #000000;
    --primary-100: #000000;
    --primary-200: #000000;
    --primary-300: #000000;
    --primary-400: #000000;
    --primary-500: #000000;
    --primary-600: #000000;
    --primary-700: #000000;
    --primary-800: #000000;
    --primary-900: #000000;

    /* Secondary Colors */
    --secondary-50: #ffffff;
    --secondary-100: #ffffff;
    --secondary-200: #ffffff;
    --secondary-300: #ffffff;
    --secondary-400: #ffffff;
    --secondary-500: #ffffff;
    --secondary-600: #ffffff;
    --secondary-700: #ffffff;
    --secondary-800: #ffffff;
    --secondary-900: #ffffff;

    /* Semantic Colors */
    --success-50: #000000;
    --success-100: #000000;
    --success-500: #000000;
    --success-600: #000000;
    --success-700: #000000;

    --warning-50: #000000;
    --warning-100: #000000;
    --warning-500: #000000;
    --warning-600: #000000;
    --warning-700: #000000;

    --error-50: #000000;
    --error-100: #000000;
    --error-500: #000000;
    --error-600: #000000;
    --error-700: #000000;

    --info-50: #000000;
    --info-100: #000000;
    --info-500: #000000;
    --info-600: #000000;
    --info-700: #000000;

    /* Neutral Colors */
    --white: #ffffff;
    --black: #000000;
    --gray-50: #ffffff;
    --gray-100: #ffffff;
    --gray-200: #ffffff;
    --gray-300: #ffffff;
    --gray-400: #ffffff;
    --gray-500: #ffffff;
    --gray-600: #000000;
    --gray-700: #000000;
    --gray-800: #000000;
    --gray-900: #000000;

    /* Background Colors */
    --bg-primary: var(--white);
    --bg-secondary: var(--white);
    --bg-tertiary: var(--white);

    /* Text Colors */
    --text-primary: var(--black);
    --text-secondary: var(--black);
    --text-tertiary: var(--black);
    --text-inverse: var(--white);

    /* Border Colors */
    --border-primary: var(--black);
    --border-secondary: var(--black);
    --border-focus: var(--black);

    /* Shadow Colors */
    --shadow-sm: 0 0 0 2px var(--black);
    --shadow-md: 0 0 0 2px var(--black);
    --shadow-lg: 0 0 0 2px var(--black);
    --shadow-xl: 0 0 0 2px var(--black);
  }

  /* ========================================
     Custom Theme Variables - משתני תמה מותאמים אישית
     ======================================== */
  
  [data-theme="custom"] {
    --custom-primary: #6366f1;
    --custom-secondary: #8b5cf6;
    --custom-accent: #06b6d4;
    --custom-background: #ffffff;
    --custom-surface: #f8fafc;
    --custom-text: #1e293b;
    --custom-text-muted: #64748b;
    --custom-border: #e2e8f0;
    --custom-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  }

  /* ========================================
     Body Background - רקע כללי לכל האתר
     ======================================== */
  
  html, body {
    background: var(--bg-page);
    background-attachment: fixed;
  }

  /* ========================================
     Shadows - צללים כלליים
     ======================================== */
  
  .shadow-sm {
    box-shadow: var(--shadow-sm);
  }
  
  .shadow {
    box-shadow: var(--shadow);
  }
  
  .shadow-md {
    box-shadow: var(--shadow-md);
  }
  
  .shadow-lg {
    box-shadow: var(--shadow-lg);
  }
  
  .shadow-xl {
    box-shadow: var(--shadow-xl);
  }
  
  .shadow-button {
    box-shadow: var(--shadow-button);
  }
  
  .shadow-card {
    box-shadow: var(--shadow-card);
  }

  /* ========================================
     Transitions - אנימציות כלליות
     ======================================== */
  
  .transition {
    transition: all var(--transition-base);
  }
  
  .transition-fast {
    transition: all var(--transition-fast);
  }
  
  .transition-slow {
    transition: all var(--transition-slow);
  }
  
  .transition-hover {
    transition: all var(--transition-hover);
  }

  /* ========================================
     Border Radius - רדיוסים כלליים
     ======================================== */
  
  .rounded-sm {
    border-radius: var(--radius-sm);
  }
  
  .rounded {
    border-radius: var(--radius-md);
  }
  
  .rounded-md {
    border-radius: var(--radius-md);
  }
  
  .rounded-lg {
    border-radius: var(--radius-lg);
  }
  
  .rounded-xl {
    border-radius: var(--radius-xl);
  }
  
  .rounded-2xl {
    border-radius: var(--radius-2xl);
  }
  
  .rounded-full {
    border-radius: var(--radius-full);
  }
  
  .rounded-button {
    border-radius: var(--radius-button);
  }
  
  .rounded-card {
    border-radius: var(--radius-card);
  }

  /* ========================================
     Typography Theme - טיפוגרפיה ערכת נושא
     ======================================== */
  
  .text-primary {
    color: var(--primary-600);
  }
  
  .text-secondary {
    color: var(--secondary-600);
  }
  
  .text-success {
    color: var(--success-500);
  }
  
  .text-danger {
    color: var(--error-500);
  }
  
  .text-warning {
    color: var(--warning-500);
  }
  
  .text-info {
    color: var(--info-500);
  }
  
  .text-muted {
    color: var(--text-muted);
  }
  
  .text-dark {
    color: var(--text-main);
  }
  
  .text-light {
    color: var(--text-inverse);
  }

  /* ========================================
     Background Colors
     ======================================== */
  
  .bg-primary {
    background-color: var(--primary-600);
  }
  
  .bg-secondary {
    background-color: var(--secondary-600);
  }
  
  .bg-success {
    background-color: var(--success-500);
  }
  
  .bg-danger {
    background-color: var(--error-500);
  }
  
  .bg-warning {
    background-color: var(--warning-500);
  }
  
  .bg-info {
    background-color: var(--info-500);
  }
  
  .bg-light {
    background-color: var(--bg-surface-soft);
  }
  
  .bg-dark {
    background-color: var(--bg-main);
  }
  
  .bg-surface {
    background-color: var(--bg-surface);
  }
  
  .bg-background {
    background-color: var(--bg-page);
  }

  /* ========================================
     Theme-aware Components - רכיבים מודעים לתמה
     ======================================== */
  
  .theme-aware-bg {
    background-color: var(--bg-primary);
  }

  .theme-aware-text {
    color: var(--text-primary);
  }

  .theme-aware-border {
    border-color: var(--border-primary);
  }

  .theme-aware-card {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-primary);
    box-shadow: var(--shadow-sm);
  }

  .theme-aware-button {
    background-color: var(--primary-600);
    color: var(--text-inverse);
    border: 1px solid var(--primary-600);
  }

  .theme-aware-button:hover {
    background-color: var(--primary-700);
    border-color: var(--primary-700);
  }

  .theme-aware-input {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
  }

  .theme-aware-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  }

  /* ========================================
     Theme Toggle Component - רכיב החלפת תמה
     ======================================== */
  
  .theme-toggle {
    position: relative;
    display: inline-flex;
    height: 1.5rem;
    width: 2.75rem;
    align-items: center;
    border-radius: 9999px;
    transition: background-color var(--transition-base);
    background-color: var(--border-secondary);
    cursor: pointer;
  }

  .theme-toggle:focus {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
  }

  .theme-toggle.active {
    background-color: var(--primary-600);
  }

  .theme-toggle-thumb {
    display: inline-block;
    height: 1rem;
    width: 1rem;
    transform: translateX(0);
    border-radius: 9999px;
    background-color: var(--surface-50);
    transition: transform var(--transition-base);
  }

  .theme-toggle.active .theme-toggle-thumb {
    transform: translateX(1.5rem);
  }

  .theme-toggle-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
  }

  .theme-toggle-icon.sun {
    left: 0.25rem;
    color: var(--warning-500);
  }

  .theme-toggle-icon.moon {
    right: 0.25rem;
    color: var(--info-500);
  }

  /* ========================================
     Theme-aware RTL Support - תמיכה RTL מודעת לתמה
     ======================================== */
  
  [dir="rtl"][data-theme="dark"] {
    --text-direction: rtl;
  }

  [dir="rtl"][data-theme="high-contrast"] {
    --text-direction: rtl;
  }

  /* ========================================
     Theme-aware Print Styles - סגנונות הדפסה מודעים לתמה
     ======================================== */
  
  @media print {
    [data-theme] {
      --bg-primary: #ffffff;
      --bg-secondary: #ffffff;
      --text-primary: #000000;
      --text-secondary: #000000;
      --border-primary: #000000;
      --shadow-sm: none;
      --shadow-md: none;
      --shadow-lg: none;
      --shadow-xl: none;
    }
    
    .theme-toggle {
      display: none;
    }
  }

  /* ========================================
     Theme-aware Reduced Motion - תנועה מופחתת מודעת לתמה
     ======================================== */
  
  @media (prefers-reduced-motion: reduce) {
    [data-theme] * {
      transition: none;
      animation: none;
    }
    
    .theme-toggle-thumb {
      transition: none;
    }
  }

  /* ========================================
     Theme-aware High Contrast Media Query - ניגודיות גבוהה מודעת לתמה
     ======================================== */
  
  @media (prefers-contrast: high) {
    [data-theme="dark"],
    .dark {
      --border-primary: #ffffff;
      --text-secondary: #ffffff;
    }
  }

  /* ========================================
     Theme-aware Color Scheme Media Query - סכמת צבעים מודעת לתמה
     ======================================== */
  
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
      --bg-primary: var(--gray-800);
      --bg-secondary: var(--gray-900);
      --text-primary: var(--gray-100);
      --text-secondary: var(--gray-300);
      --border-primary: var(--gray-700);
    }
  }

  /* הוסר: prefers-color-scheme: light - רק dark mode נתמך */
}

/* ============================================
   Theme Selector UI - ממשק בחירת תמה
   ============================================ */

@layer components {
  /* Theme Selector Container */
  .theme-selector {
    position: relative;
    display: inline-block;
  }

  /* כפתור בחירת תמה */
  .theme-selector-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
  }

  .theme-selector-btn:hover {
    background: var(--primary-soft);
    border-color: var(--primary-300);
    color: var(--primary-700);
  }

  .theme-selector-btn i {
    font-size: 1rem;
  }

  .theme-selector-label {
    display: none;
  }

  @media (min-width: 768px) {
    .theme-selector-label {
      display: inline;
    }
  }

  /* Dropdown */
  .theme-selector-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    inset-inline-end: 0;
    min-width: 280px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 0.5rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity var(--transition-base), visibility var(--transition-base), transform var(--transition-base);
    z-index: var(--z-dropdown);
  }

  .theme-selector-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  /* Theme Option */
  .theme-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
    position: relative;
  }

  .theme-option:hover {
    background: var(--primary-soft);
  }

  .theme-option.active {
    background: var(--primary-soft-strong);
  }

  /* תצוגה מקדימה */
  .theme-option-preview {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
  }

  .theme-preview-light {
    background: linear-gradient(135deg, var(--secondary-50) 0%, var(--secondary-200) 55%, var(--secondary-300) 100%);
  }

  .theme-preview-light::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 30%;
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid rgba(148, 163, 184, 0.35);
  }

  .theme-preview-light::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70%;
    background: var(--bg-surface);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
  }

  .theme-preview-dark {
    background: linear-gradient(135deg, var(--secondary-900) 0%, var(--secondary-800) 50%, var(--secondary-700) 100%);
  }

  .theme-preview-dark::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 30%;
    background: rgba(44, 62, 80, 0.95);
    border-bottom: 1px solid rgba(148, 163, 184, 0.35);
  }

  .theme-preview-dark::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70%;
    background: var(--secondary-700);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
  }

  .theme-preview-auto {
    background: linear-gradient(135deg, var(--secondary-50) 0%, var(--secondary-900) 100%);
    position: relative;
  }

  .theme-preview-auto::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid rgba(148, 163, 184, 0.35);
  }

  .theme-preview-auto::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: var(--secondary-700);
  }

  /* מידע על תמה */
  .theme-option-info {
    flex: 1;
    min-width: 0;
  }

  .theme-option-name {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-main);
    margin-bottom: 0.15rem;
  }

  .theme-option-desc {
    font-size: var(--text-xs);
    color: var(--text-muted);
  }

  /* סימן בחירה */
  .theme-option-check {
    color: var(--primary-600);
    font-size: 1rem;
    display: none;
  }

  .theme-option.active .theme-option-check {
    display: block;
  }

  /* RTL Support */
  html[dir="rtl"] .theme-selector-dropdown {
    inset-inline-end: 0;
    inset-inline-start: auto;
  }

  /* Responsive */
  @media (max-width: 767px) {
    .theme-selector-dropdown {
      min-width: 240px;
    }
    
    .theme-selector-label {
      display: none;
    }
  }

  /* Dark Theme - עיצוב כפתור בחירת תמה */
  [data-theme="dark"] .theme-selector-btn {
    background: var(--bg-surface);
    border-color: var(--border-subtle);
    color: var(--text-secondary);
  }

  [data-theme="dark"] .theme-selector-btn:hover {
    background: var(--primary-soft);
    border-color: var(--primary-300);
    color: var(--primary);
  }

  [data-theme="dark"] .theme-selector-dropdown {
    background: var(--bg-surface);
    border-color: var(--border-subtle);
    box-shadow: var(--shadow-card);
  }

  [data-theme="dark"] .theme-option:hover {
    background: var(--primary-soft);
  }

  [data-theme="dark"] .theme-option.active {
    background: var(--primary-soft-strong);
  }

  [data-theme="dark"] .theme-option-name {
    color: var(--text-main);
  }

  [data-theme="dark"] .theme-option-desc {
    color: var(--text-muted);
  }

  /* הוסר: Light Theme - רק dark mode נתמך */
}
