/**
 * ALLEGRO FLEET — Design System Components (Sprint 4 Lock)
 * Reusable patterns: dark panel, table wrapper, sticky header, empty state, filter bar, etc.
 * Cilj: smanjiti ad-hoc CSS, standardizirati nove ekrane.
 */

/* ============================================
   DARK PANEL / CARD
   ============================================ */
.ds-panel,
.card.ds-panel {
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
}

.ds-panel-header {
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-muted);
  font-weight: var(--font-weight-semibold);
}

/* ============================================
   TABLE WRAPPER (scrollable, sticky header)
   ============================================ */
.ds-table-scroll {
  max-height: 400px;
  overflow-y: auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.ds-table-scroll thead th {
  position: sticky;
  top: 0;
  background: var(--bg-surface) !important;
  z-index: 2;
  box-shadow: 0 1px 0 var(--border-muted);
}

/* Mobile: reduce max-height for smaller screens */
@media (max-width: 767px) {
  .ds-table-scroll {
    max-height: 300px;
  }
}

/* ============================================
   SUMMARY STAT BLOCK
   ============================================ */
.ds-summary-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  padding: var(--space-3) 0;
}

.ds-summary-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 60px;
}

.ds-summary-stat-value {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
}

.ds-summary-stat-label {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

/* ============================================
   FILTER BAR
   ============================================ */
.ds-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  padding: var(--space-3) 0;
}

.ds-filter-bar .btn-group .btn {
  min-height: 36px;
}

@media (max-width: 575px) {
  .ds-filter-bar {
    gap: var(--space-1);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--space-2);
    margin-bottom: var(--space-2);
  }
  .ds-filter-bar .btn-group {
    flex-wrap: nowrap;
  }
  .ds-filter-bar .btn-group .btn {
    padding: 0.35rem 0.5rem;
    font-size: var(--font-size-xs);
    white-space: nowrap;
  }
}

/* ============================================
   EMPTY STATE
   ============================================ */
.ds-empty-state {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  color: var(--text-muted);
}

.ds-empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-3);
  opacity: 0.5;
}

.ds-empty-state-title {
  font-weight: var(--font-weight-medium);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.ds-empty-state-text {
  font-size: var(--font-size-sm);
  max-width: 320px;
  margin: 0 auto;
}

/* ============================================
   ACTION BUTTON GROUP (operativne akcije)
   ============================================ */
.ds-action-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.ds-action-group .btn {
  min-height: 36px;
}

@media (max-width: 575px) {
  .ds-action-group {
    flex-direction: column;
    align-items: stretch;
  }
  .ds-action-group .btn {
    width: 100%;
  }
}

/* ============================================
   MEDIA THUMBNAIL (consistent ratio)
   ============================================ */
.ds-thumb {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: var(--radius-md);
}

.ds-thumb-sm {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.ds-thumb-md {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius-md);
}

/* ============================================
   SECTION HEADING
   ============================================ */
.ds-section-heading {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.ds-section-heading i {
  color: var(--text-muted);
}

/* ============================================
   CLICKABLE CARD (enhanced)
   ============================================ */
.ds-clickable-card {
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.ds-clickable-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}

.ds-clickable-card:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* ============================================
   FOCUS-VISIBLE (accessibility)
   ============================================ */
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
[tabindex="0"]:focus-visible,
.clickable-card:focus-visible,
.ds-clickable-card:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* Cursor pointer na klikabilnim elementima */
.clickable-card,
.ds-clickable-card,
[data-href],
[role="button"] {
  cursor: pointer;
}

/* ============================================
   MOBILE: Touch targets, overflow
   ============================================ */
/* Mobile: ensure primary action buttons have adequate touch target */
@media (max-width: 575px) {
  .btn-primary,
  .btn-success,
  a.btn-primary,
  a.btn-success {
    min-height: 44px;
    padding: 0.5rem 1rem;
  }
}

/* Horizontal scroll hint for wide tables */
.table-responsive {
  -webkit-overflow-scrolling: touch;
}
