/* ============================================
   מרכז Styles - עיצוב מרכז לכל המודולים
   ============================================ */

@layer components {
  /* ===== מרכז Container ===== */
  .users-hub,
  .projects-hub,
  .contractors-hub,
  .employees-hub,
  .contracts-hub,
  .accounts-hub,
  .documents-hub,
  .reports-hub,
  .email-hub,
  .worklogs-hub,
  .orders-hub,
  .invoices-hub,
  .chat-hub,
  .equipment-hub,
  .suppliers-hub,
  .settings-hub,
  .safety-hub,
  .gantt-hub,
  .materials-hub,
  .groups-hub {
    padding: var(--sp-4) 0;
    max-width: var(--page-max-width, 1280px); /* ✅ תיקון לפי חוק זהב #1 */
    margin-inline: auto; /* ✅ תיקון לפי חוק זהב #1 */
    width: 100%; /* ✅ תיקון לפי חוק זהב #1 */
  }

  /* ===== כרטיסי KPI ===== */
  /* מובייל - 2 בשורה */
  .kpi-cards-grid {
    display: grid; /* ✅ תיקון לפי חוק זהב #5 */
    grid-template-columns: repeat(2, 1fr); /* 2 בשורה במובייל */
    gap: var(--sp-4); /* ✅ תיקון לפי חוק זהב #5 - gap אחיד */
    margin-bottom: var(--sp-4);
    width: 100%; /* ✅ תיקון לפי חוק זהב #5 */
    box-sizing: border-box; /* ✅ תיקון לפי חוק זהב #5 */
  }
  
  /* טאבלט קטן - 2 עמודות (אותו דבר) */
  @media (min-width: 640px) {
    .kpi-cards-grid {
      grid-template-columns: repeat(2, 1fr);
    }
  }
  
  /* ✅ Mobile-First - ברירת מחדל למובייל (כבר מוגדר למעלה) */
  /* טאבלט - 3 עמודות */
  @media (min-width: 768px) {
    .kpi-cards-grid {
      grid-template-columns: repeat(2, 1fr); /* טאבלט */
    }
  }
  
  /* דסקטופ - 3 עמודות */
  @media (min-width: 1024px) {
    .kpi-cards-grid {
      grid-template-columns: repeat(3, 1fr); /* דסקטופ */
    }
  }
  
  /* דסקטופ גדול - 5 עמודות בשורה אחת */
  @media (min-width: 1200px) {
    .kpi-cards-grid {
      grid-template-columns: repeat(5, 1fr); /* דסקטופ גדול */
    }
  }

  /* ✅ תיקון לפי חוק זהב #5 - במובייל צר: כל כרטיס 100% רוחב */
  @media (max-width: 576px) {
    .kpi-cards-grid {
      grid-template-columns: 1fr; /* ✅ תיקון לפי חוק זהב #5 - במובייל צר: עמודה אחת */
    }
  }

  .kpi-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: var(--sp-5);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    transition: all 0.15s ease;
    color: var(--text-main);
  }

  .kpi-card:hover {
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.9);
    transform: translateY(-2px);
    background: var(--bg-surface-soft);
    border-color: var(--border-strong);
  }

  .kpi-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--text-inverse);
    flex-shrink: 0;
  }

  .kpi-primary .kpi-icon {
    background: var(--primary-500);
  }

  .kpi-success .kpi-icon {
    background: var(--success-500);
  }

  .kpi-warning .kpi-icon {
    background: var(--warning-500);
  }

  .kpi-info .kpi-icon {
    background: var(--info-500);
  }

  .kpi-secondary .kpi-icon {
    background: var(--secondary-500);
  }

  .kpi-dark .kpi-icon {
    background: var(--gray-700);
  }

  .kpi-content {
    flex: 1;
  }

  .kpi-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
    margin-bottom: var(--sp-1);
  }

  .kpi-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: var(--sp-2);
  }

  .kpi-link {
    font-size: 12px;
    color: var(--primary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    transition: color 0.2s ease;
  }

  .kpi-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
  }

  /* ===== טאבים ===== */
  .hub-tabs-container {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: var(--sp-2);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-subtle);
    margin-bottom: var(--sp-4);
    overflow: visible;
    max-height: none;
    height: auto;
  }

  .hub-tabs {
    display: flex;
    gap: var(--sp-2);
    overflow-x: auto;
    overflow-y: visible;
    scrollbar-width: thin;
    max-height: none;
    height: auto;
  }

  .hub-tab {
    background: transparent;
    border: none;
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.15s ease;
    white-space: nowrap;
    position: relative;
    overflow-x: visible;
    overflow-y: visible;
    max-width: none;
    width: auto;
    flex-shrink: 0;
  }

  .hub-tab:hover {
    background: rgba(77, 163, 255, 0.12);
    color: var(--text-main);
  }

  .hub-tab.active {
    background: var(--primary);
    color: var(--text-on-primary);
    box-shadow: 0 4px 12px rgba(77, 163, 255, 0.4);
  }

  .hub-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 3px;
    background: var(--primary-dark);
    border-radius: 2px 2px 0 0;
  }

  .hub-tab i {
    font-size: 16px;
  }

  /* ===== תוכן טאבים ===== */
  .hub-tabs-content {
    position: relative;
  }

  .hub-tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
  }

  .hub-tab-content.active {
    display: block;
  }

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

  /* ===== פעולות מהירות - סיידבר קומפקטי עם אפקט גלילה ===== */
  .quick-actions-section {
    position: relative;
    margin-bottom: 2rem;
  }

  /* כפתור פתיחה/סגירה */
  .quick-actions-toggle-btn {
    position: absolute;
    top: 0;
    right: 0;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 12px 0 0 12px;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
    padding: 0;
  }

  .quick-actions-toggle-btn:hover {
    width: 52px;
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.2);
    transform: translateX(-2px);
  }

  .quick-actions-toggle-btn i {
    font-size: 1.25rem;
    transition: transform 0.3s ease;
  }

  .quick-actions-toggle-btn.collapsed i {
    transform: rotate(180deg);
  }

  /* פאנל פעולות מהירות */
  .quick-actions-panel {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 500px;
    overflow: hidden;
  }

  .quick-actions-panel.collapsed {
    max-height: 0;
    padding: 0 1.25rem;
    margin: 0;
    border: none;
    opacity: 0;
  }

  .quick-actions-panel.expanded {
    max-height: 500px;
    padding: 1.25rem;
    opacity: 1;
  }

  /* כותרת פאנל */
  .quick-actions-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border-subtle);
  }

  .quick-actions-panel-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  .quick-actions-panel-header-left i {
    color: var(--primary);
    font-size: 1rem;
  }

  .quick-actions-panel-header-left h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-main);
  }

  .quick-actions-panel-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
  }

  .quick-actions-panel-close:hover {
    background: var(--bg-surface-soft);
    color: var(--text-main);
  }

  .section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border-subtle);
  }

  .section-title i {
    color: var(--primary);
    font-size: 1.1rem;
  }

  .quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    direction: rtl;
  }

  @media (max-width: 768px) {
    .quick-actions-grid {
      grid-template-columns: repeat(2, 1fr); /* 2 בשורה במובייל */
      gap: 0.75rem;
    }
  }

  .quick-action-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-main);
    background: var(--bg-surface-soft);
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    text-decoration: none;
    position: relative;
    overflow: hidden;
    min-height: 120px;
    text-align: center;
    z-index: 1;
  }

  .quick-action-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 0;
    pointer-events: none;
  }

  .quick-action-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15), 0 4px 8px rgba(0, 0, 0, 0.1);
    border-color: var(--primary);
    text-decoration: none;
  }

  .quick-action-card:hover::before {
    opacity: 0.05;
  }

  .quick-action-card:hover .quick-action-icon {
    transform: scale(1.1);
    color: var(--primary);
  }

  .quick-action-card:hover .quick-action-content h4 {
    color: var(--primary);
  }

  .quick-action-icon {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(77, 163, 255, 0.1), rgba(56, 103, 214, 0.1));
    border-radius: 12px;
    margin-bottom: 0.75rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 2;
    pointer-events: none;
  }

  .quick-action-icon i {
    font-size: 1.5rem;
    color: var(--primary);
    transition: all 0.3s ease;
  }

  .quick-action-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    position: relative;
    z-index: 2;
    width: 100%;
    pointer-events: none;
  }

  .quick-action-content h4 {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-main);
    line-height: 1.4;
    transition: color 0.3s ease;
  }

  .quick-action-content p {
    font-size: 0.8rem;
    margin: 0;
    color: var(--text-muted);
    line-height: 1.4;
    display: block;
  }

  /* ===== תצוגה מקדימה ===== */
  .preview-section {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: var(--sp-5);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-subtle);
    margin-bottom: var(--sp-4);
    color: var(--text-main);
  }

  .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--sp-4);
  }

  .view-all-link {
    font-size: 14px;
    color: var(--primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    transition: color 0.2s ease;
  }

  .view-all-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
  }

  /* ===== טבלאות ===== */
  /* הטבלאות משתמשות בעיצוב הגלובלי מ-tables.css */
  
  /* הגבלת גובה לטבלאות ב-hub */
  .documents-hub .table-wrapper {
    max-height: 500px;
    overflow-y: auto;
    overflow-x: auto;
    position: relative;
  }

  /* הגבלת רוחב עמודת סוג */
  .documents-hub .table th:nth-child(2),
  .documents-hub .table td:nth-child(2) {
    max-width: 120px;
    min-width: 80px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .documents-hub .table td:nth-child(2) .badge-secondary {
    max-width: 100%;
    display: inline-block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* הגבלת רוחב עמודת "הועלה על ידי" */
  .documents-hub .table th:nth-child(5),
  .documents-hub .table td:nth-child(5) {
    max-width: 150px;
    min-width: 100px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .documents-hub .table-wrapper::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

  .documents-hub .table-wrapper::-webkit-scrollbar-thumb {
    background: var(--border-primary);
    border-radius: 4px;
  }

  .documents-hub .table-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
  }

  .documents-hub .table-wrapper::-webkit-scrollbar-track {
    background: var(--bg-secondary);
  }


  /* ===== כפתורי פעולה ===== */
  .action-buttons {
    display: flex;
    gap: var(--sp-2);
  }

  .action-buttons .btn {
    padding: var(--sp-1) var(--sp-2);
    font-size: 12px;
  }

  /* ===== Info Box ===== */
  .info-box {
    background: var(--info-soft);
    border: 1px solid var(--info);
    border-radius: var(--radius-md);
    padding: var(--sp-4);
  }

  .info-box-content h4 {
    font-size: 32px;
    font-weight: 700;
    color: var(--info);
    margin-bottom: var(--sp-1);
  }

  .info-box-content p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
  }

  /* ===== Responsive ===== */
  @media (max-width: 768px) {
    .kpi-cards-grid {
      grid-template-columns: 1fr;
    }

    .quick-actions-grid {
      grid-template-columns: 1fr;
    }

    .hub-tabs {
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
    }

    .hub-tab {
      min-width: 120px;
    }
  }

  @media (max-width: 576px) {
    .kpi-cards-grid {
      grid-template-columns: 1fr;
    }
  }
}

