/* ============================================
   Devices Page - Modern Stílusok
   Az Elsys CO2 dizájn mintájára
   ============================================ */

/* ==================== DEVICES GRID ==================== */
.devices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
  margin: 1.5rem 0;
}

/* ==================== DEVICE CARD ==================== */
.device-card {
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 16px;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.device-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #06b6d4 0%, #3b82f6 50%, #8b5cf6 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.device-card:hover::before {
  opacity: 1;
}

.device-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(59, 130, 246, 0.15);
  border-color: var(--accent-primary, #3b82f6);
}

/* Card Header */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.25rem 0.75rem;
}

.card-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: linear-gradient(135deg, var(--primary, #3b82f6) 0%, #2563eb 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

/* Status Badge - Elsys stílus */
.card-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-status.online {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.card-status.offline {
  background: rgba(107, 114, 128, 0.2);
  color: #6b7280;
  border: 1px solid rgba(107, 114, 128, 0.3);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.card-status.online .status-indicator {
  animation: online-pulse 2s ease-in-out infinite;
  box-shadow: 0 0 8px currentColor;
}

@keyframes online-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.9); }
}

/* Card Body */
.card-body {
  padding: 0 1.25rem 1rem;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary, #1a1a1a);
  margin: 0 0 0.35rem 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-type {
  font-size: 0.75rem;
  color: var(--text-secondary, #6b7280);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.card-location {
  font-size: 0.85rem;
  color: var(--text-secondary, #6b7280);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.card-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0.75rem 0;
  color: var(--text-primary, #1a1a1a);
}

.card-secondary {
  font-size: 0.9rem;
  color: var(--text-secondary, #6b7280);
  margin-bottom: 0.75rem;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border, #e5e7eb);
  margin-top: 0.75rem;
  font-size: 0.75rem;
}

.card-eui {
  font-family: var(--font-mono, 'SF Mono', 'Monaco', 'Consolas', monospace);
  color: var(--text-tertiary, #9ca3af);
  letter-spacing: 0.5px;
}

.card-lastseen {
  color: var(--text-tertiary, #9ca3af);
}

/* Card Actions - Elsys stílus */
.card-actions {
  display: flex;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border, #e5e7eb);
  background: var(--bg-secondary, #f9fafb);
}

.card-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  border: none;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.card-btn.primary {
  flex: 1;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

.card-btn.primary:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.card-btn.icon {
  width: 40px;
  height: 40px;
  padding: 0;
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border, #e5e7eb);
  color: var(--text-secondary, #6b7280);
}

.card-btn.icon:hover {
  background: var(--bg-hover, #f3f4f6);
  border-color: var(--accent-primary, #3b82f6);
  color: var(--text-primary, #1a1a1a);
}

.card-btn.icon.danger:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: #ef4444;
  color: #ef4444;
}

/* ==================== PAGE HEADER - Elsys stílus ==================== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.5rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1px solid #bae6fd;
  border-radius: 16px;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.1);
}

.header-left h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: #0c4a6e;
  margin: 0 0 0.25rem 0;
}

.subtitle {
  color: #0369a1;
  font-size: 0.9rem;
  margin: 0;
  opacity: 0.9;
}

.header-right {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

/* Search Box - Elsys stílus */
.search-box {
  position: relative;
  min-width: 280px;
}

.search-input {
  width: 100%;
  padding: 0.75rem 1rem;
  padding-left: 2.75rem;
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  color: var(--text-primary, #1a1a1a);
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-primary, #3b82f6);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  color: var(--text-secondary, #6b7280);
  pointer-events: none;
}

/* ==================== STATISTICS CARDS - Elsys stílus ==================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius-lg, 12px);
  padding: 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1rem;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* Gradient top border hover */
.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #06b6d4 0%, #3b82f6 50%, #8b5cf6 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.stat-card:hover::before {
  opacity: 1;
}

.stat-card:hover {
  border-color: var(--accent-primary, #3b82f6);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.15);
}

.stat-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: linear-gradient(135deg, var(--accent-primary, #3b82f6) 0%, #2563eb 100%);
  border-radius: var(--radius-md, 10px);
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
  margin-bottom: 0.5rem;
}

.stat-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.stat-content h3 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary, #1a1a1a);
  margin: 0;
  line-height: 1.2;
  text-align: center;
}

.stat-content p {
  font-size: 0.8rem;
  color: var(--text-secondary, #6b7280);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  text-align: center;
}

/* ✅ FONTOS: stat-status is középre */
.stat-status {
  font-size: 0.75rem;
  color: var(--text-tertiary, #9ca3af);
  display: flex;
  align-items: center;
  justify-content: center;  /* ← KÖZÉPRE */
  gap: 0.25rem;
  width: 100%;
  margin-top: 0.25rem;
  text-align: center;  /* ← KÖZÉPRE */
}

.stat-status.positive {
  color: var(--success, #10b981);
}

.stat-status.negative {
  color: var(--danger, #ef4444);
}

/* ==================== FILTER PILLS - Elsys stílus ==================== */
.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.pill {
  padding: 0.5rem 1rem;
  background: var(--bg-secondary, #f9fafb);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 20px;
  color: var(--text-secondary, #6b7280);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.pill:hover {
  background: var(--bg-hover, #f3f4f6);
  border-color: var(--accent-primary, #3b82f6);
  color: var(--text-primary, #1a1a1a);
}

.pill.active {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  border-color: transparent;
  color: white;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

/* ==================== EMPTY STATE - Elsys stílus ==================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 2rem;
  background: var(--bg-card, #ffffff);
  border: 2px dashed var(--border, #e5e7eb);
  border-radius: 16px;
  margin: 2rem 0;
}

.empty-state .empty-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.4;
  filter: grayscale(100%);
}

.empty-state h3 {
  font-size: 1.25rem;
  color: var(--text-primary, #1a1a1a);
  font-weight: 600;
  margin: 0 0 0.5rem 0;
}

.empty-state p {
  color: var(--text-secondary, #6b7280);
  margin: 0;
  max-width: 400px;
}

/* ==================== FORM STYLES - Elsys stílus ==================== */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  color: var(--text-primary, #1a1a1a);
  font-weight: 600;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-secondary, #f9fafb);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  color: var(--text-primary, #1a1a1a);
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-primary, #3b82f6);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
  background: var(--bg-card, #ffffff);
}

.form-control:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--bg-secondary, #f9fafb);
}

/* ==================== LOADING - Elsys stílus ==================== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border, #e5e7eb);
  border-top-color: var(--accent-primary, #3b82f6);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  color: var(--text-secondary, #6b7280);
  font-size: 0.9rem;
  font-weight: 500;
}

/* ==================== BUTTONS - Elsys stílus ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border, #e5e7eb);
  color: var(--text-secondary, #6b7280);
}

.btn-secondary:hover {
  background: var(--bg-hover, #f3f4f6);
  border-color: var(--text-secondary, #6b7280);
  color: var(--text-primary, #1a1a1a);
}

.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}

.btn-success:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
  transform: translateY(-1px);
}

.btn-sm {
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
}

/* ==================== ALERTS - Elsys stílus ==================== */
.alert {
  padding: 1rem 1.25rem;
  border-radius: 10px;
  margin: 1rem 0;
  border-left: 4px solid;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: alertSlideIn 0.3s ease;
}

@keyframes alertSlideIn {
  from {
    transform: translateX(-10px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.alert-warning {
  background: rgba(245, 158, 11, 0.1);
  border-color: #f59e0b;
  color: #b45309;
}

.alert-info {
  background: rgba(59, 130, 246, 0.1);
  border-color: #3b82f6;
  color: #1d4ed8;
}

.alert-success {
  background: rgba(16, 185, 129, 0.1);
  border-color: #10b981;
  color: #047857;
}

.alert-danger {
  background: rgba(239, 68, 68, 0.1);
  border-color: #ef4444;
  color: #b91c1c;
}

/* ==================== DEVICE TYPE SPECIFIC COLORS ==================== */
.device-card.thermostat .card-icon {
  background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
}

.device-card.thermostat::before {
  background: linear-gradient(90deg, #f97316 0%, #ef4444 50%, #dc2626 100%);
}

.device-card.sensor .card-icon {
  background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
}

.device-card.sensor::before {
  background: linear-gradient(90deg, #06b6d4 0%, #3b82f6 50%, #8b5cf6 100%);
}

.device-card.smartplug .card-icon {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.device-card.smartplug::before {
  background: linear-gradient(90deg, #10b981 0%, #059669 50%, #047857 100%);
}

.device-card.valve .card-icon {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
}

.device-card.valve::before {
  background: linear-gradient(90deg, #8b5cf6 0%, #7c3aed 50%, #6d28d9 100%);
}

/* ==================== RESPONSIVE - Elsys stílus ==================== */
@media (max-width: 768px) {
  .page-header {
    flex-direction: column;
    align-items: stretch;
    padding: 1.25rem;
  }
  
  .header-right {
    width: 100%;
  }
  
  .search-box {
    min-width: 100%;
    flex: 1;
  }
  
  .devices-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
  
  .filter-pills {
    padding: 0.75rem 1rem;
  }
  
  .pill {
    font-size: 0.8rem;
    padding: 0.4rem 0.75rem;
  }
  
  .card-header {
    padding: 1rem 1rem 0.75rem;
  }
  
  .card-body {
    padding: 0 1rem 1rem;
  }
  
  .card-actions {
    padding: 0.75rem 1rem;
  }
}

@media (max-width: 480px) {
  .header-left h1 {
    font-size: 1.5rem;
  }
  
  .page-header {
    padding: 1rem;
    border-radius: 12px;
  }
  
  .stat-card {
    padding: 1rem;
  }
  
  .stat-content h3 {
    font-size: 1.5rem;
  }
  
  .stat-icon {
    width: 40px;
    height: 40px;
    font-size: 1.25rem;
  }
  
  .card-value {
    font-size: 1.75rem;
  }
  
  .card-icon {
    width: 40px;
    height: 40px;
    font-size: 1.25rem;
  }
  
  .devices-grid {
    gap: 0.75rem;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* ==================== DARK MODE - Elsys stílus ==================== */
[data-theme="dark"] .device-card {
  background: var(--bg-card, #1f2937);
  border-color: var(--border, #374151);
}

[data-theme="dark"] .card-actions {
  background: var(--bg-secondary, #111827);
  border-color: var(--border, #374151);
}

[data-theme="dark"] .card-btn.icon {
  background: var(--bg-secondary, #111827);
  border-color: var(--border, #374151);
}

[data-theme="dark"] .page-header {
  background: linear-gradient(135deg, #1e3a5f 0%, #1e40af 100%);
  border-color: #3b82f6;
}

[data-theme="dark"] .header-left h1 {
  color: #e0f2fe;
}

[data-theme="dark"] .subtitle {
  color: #93c5fd;
}

[data-theme="dark"] .search-input {
  background: var(--bg-secondary, #111827);
  border-color: var(--border, #374151);
  color: var(--text-primary, #f9fafb);
}

[data-theme="dark"] .search-input:focus {
  background: var(--bg-card, #1f2937);
}

[data-theme="dark"] .stat-card {
  background: var(--bg-card, #1f2937);
  border-color: var(--border, #374151);
}

[data-theme="dark"] .filter-pills {
  background: var(--bg-card, #1f2937);
  border-color: var(--border, #374151);
}

[data-theme="dark"] .pill {
  background: var(--bg-secondary, #111827);
  border-color: var(--border, #374151);
  color: var(--text-secondary, #9ca3af);
}

[data-theme="dark"] .pill:hover {
  background: var(--bg-hover, #374151);
  color: var(--text-primary, #f9fafb);
}

[data-theme="dark"] .empty-state {
  background: var(--bg-card, #1f2937);
  border-color: var(--border, #374151);
}

[data-theme="dark"] .loading-overlay {
  background: rgba(17, 24, 39, 0.95);
}

[data-theme="dark"] .form-control {
  background: var(--bg-secondary, #111827);
  border-color: var(--border, #374151);
  color: var(--text-primary, #f9fafb);
}

[data-theme="dark"] .form-control:focus {
  background: var(--bg-card, #1f2937);
}

[data-theme="dark"] .form-control:disabled {
  background: var(--bg-secondary, #111827);
}

[data-theme="dark"] .btn-secondary {
  background: var(--bg-card, #1f2937);
  border-color: var(--border, #374151);
  color: var(--text-secondary, #9ca3af);
}

[data-theme="dark"] .btn-secondary:hover {
  background: var(--bg-hover, #374151);
  color: var(--text-primary, #f9fafb);
}

/* ==================== ANIMATIONS ==================== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.device-card {
  animation: fadeIn 0.3s ease;
}

.stat-card {
  animation: fadeIn 0.3s ease;
}

/* Stagger animation for multiple cards */
.device-card:nth-child(1) { animation-delay: 0s; }
.device-card:nth-child(2) { animation-delay: 0.05s; }
.device-card:nth-child(3) { animation-delay: 0.1s; }
.device-card:nth-child(4) { animation-delay: 0.15s; }
.device-card:nth-child(5) { animation-delay: 0.2s; }
.device-card:nth-child(6) { animation-delay: 0.25s; }

.stat-card:nth-child(1) { animation-delay: 0s; }
.stat-card:nth-child(2) { animation-delay: 0.05s; }
.stat-card:nth-child(3) { animation-delay: 0.1s; }
.stat-card:nth-child(4) { animation-delay: 0.15s; }