/* ============================================
   Automation Page - Modern Stílusok
   Elsys CO2 dizájn mintájára
   ============================================ */

/* ==================== RULES GRID ==================== */
.rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 1.25rem;
  margin: 1.5rem 0;
}

/* ==================== RULE CARD - Elsys stílus ==================== */
.rule-card {
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius-xl, 16px);
  padding: 1.5rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.rule-card.disabled {
  opacity: 0.6;
}

/* Gradient top border - Elsys stílus */
.rule-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;
}

.rule-card:hover::before {
  opacity: 1;
}

.rule-card:hover {
  border-color: var(--accent-primary, #3b82f6);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.15);
}

/* ==================== RULE STATUS INDICATOR ==================== */
.rule-status {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.rule-status.active {
  background: var(--success, #10b981);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
  animation: online-pulse 2s ease-in-out infinite;
}

.rule-status.disabled {
  background: var(--text-tertiary, #9ca3af);
  box-shadow: none;
}

@keyframes online-pulse {
  0%, 100% { 
    opacity: 1; 
    transform: scale(1); 
  }
  50% { 
    opacity: 0.6; 
    transform: scale(0.9); 
  }
}

/* ==================== RULE HEADER ==================== */
.rule-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border, #e5e7eb);
}

.rule-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary, #1a1a1a);
  margin: 0;
  padding-right: 2rem;
  flex: 1;
  line-height: 1.4;
}

.rule-badge {
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.badge-success {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-secondary {
  background: rgba(107, 114, 128, 0.1);
  color: #6b7280;
  border: 1px solid rgba(107, 114, 128, 0.3);
}

/* ==================== RULE DESCRIPTION ==================== */
.rule-description {
  color: var(--text-secondary, #6b7280);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  line-height: 1.6;
}

/* ==================== RULE TRIGGER & ACTION - Elsys stílus ==================== */
.rule-trigger,
.rule-action {
  background: var(--bg-secondary, #f9fafb);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius-md, 10px);
  padding: 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.rule-trigger:hover,
.rule-action:hover {
  background: var(--bg-hover, #f3f4f6);
}

.rule-trigger strong,
.rule-action strong {
  color: var(--text-primary, #1a1a1a);
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent-primary, #3b82f6);
}

.rule-trigger {
  border-left: 3px solid #3b82f6;
}

.rule-action {
  border-left: 3px solid #f97316;
}

/* ==================== RULE STATS ==================== */
.rule-stats {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  background: var(--bg-secondary, #f9fafb);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius-md, 10px);
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-secondary, #6b7280);
}

.rule-stats > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.rule-stats strong {
  color: var(--text-primary, #1a1a1a);
  font-weight: 600;
}

/* ==================== RULE CONTROLS ==================== */
.rule-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border, #e5e7eb);
}

.rule-controls .btn {
  flex: 1;
  min-width: 100px;
  font-size: 0.85rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-md, 10px);
  font-weight: 600;
  transition: all 0.2s ease;
}

.rule-controls .btn-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  border: none;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

.rule-controls .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);
}

.rule-controls .btn-secondary {
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border, #e5e7eb);
  color: var(--text-secondary, #6b7280);
}

.rule-controls .btn-secondary:hover {
  background: var(--bg-hover, #f3f4f6);
  border-color: var(--text-secondary, #6b7280);
  color: var(--text-primary, #1a1a1a);
}

.rule-controls .btn-danger {
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border, #e5e7eb);
  color: #ef4444;
}

.rule-controls .btn-danger:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: #ef4444;
}

/* ==================== PAGE HEADER - Elsys stílus ==================== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1px solid #bae6fd;
  border-radius: var(--radius-xl, 16px);
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.1);
}

.page-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #06b6d4 0%, #3b82f6 50%, #8b5cf6 100%);
}

.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;
}

/* ==================== 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);
}

/* ==================== 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: var(--radius-xl, 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;
  font-weight: 600;
  color: var(--text-primary, #1a1a1a);
  margin: 0 0 0.5rem 0;
}

.empty-state p {
  color: var(--text-secondary, #6b7280);
  margin: 0 0 1.5rem 0;
  font-size: 0.95rem;
  max-width: 400px;
}

/* ==================== FORM ELEMENTS - 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: var(--radius-md, 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);
}

.form-group small {
  display: block;
  color: var(--text-tertiary, #9ca3af);
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

/* Select styling */
select.form-control {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

/* ==================== MODAL SECTIONS ==================== */
.modal-content h3 {
  color: var(--text-primary, #1a1a1a);
  font-size: 1.1rem;
  font-weight: 600;
  margin: 1.5rem 0 1rem 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border, #e5e7eb);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-content h3:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

/* ==================== BUTTON GROUP ==================== */
.button-group {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.button-group .btn {
  padding: 0.75rem 1.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-md, 10px);
  transition: all 0.2s ease;
}

/* ==================== LOADING OVERLAY - 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;
}

[data-theme="dark"] .loading-overlay {
  background: rgba(15, 23, 42, 0.95);
}

.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.95rem;
  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: var(--radius-md, 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-danger {
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border, #e5e7eb);
  color: #ef4444;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: #ef4444;
}

.btn-sm {
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

/* ==================== DARK MODE - Elsys stílus ==================== */
[data-theme="dark"] .rule-card {
  background: var(--bg-card, #1f2937);
  border-color: var(--border, #374151);
}

[data-theme="dark"] .rule-trigger,
[data-theme="dark"] .rule-action,
[data-theme="dark"] .rule-stats {
  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"] .stat-card {
  background: var(--bg-card, #1f2937);
  border-color: var(--border, #374151);
}

[data-theme="dark"] .empty-state {
  background: var(--bg-card, #1f2937);
  border-color: var(--border, #374151);
}

[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"] .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);
}

[data-theme="dark"] .btn-danger {
  background: var(--bg-card, #1f2937);
  border-color: var(--border, #374151);
}

/* ==================== RESPONSIVE - Mobile First ==================== */
@media (max-width: 768px) {
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 1.25rem;
    padding: 1.25rem;
  }
  
  .header-right {
    width: 100%;
    flex-wrap: wrap;
  }
  
  .header-right .btn {
    flex: 1;
    min-width: 120px;
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
  
  .rules-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .rule-card {
    padding: 1.25rem;
  }
  
  .rule-controls {
    flex-direction: column;
  }
  
  .rule-controls .btn {
    width: 100%;
  }
  
  .button-group {
    flex-direction: column;
  }
  
  .button-group .btn {
    width: 100%;
  }
}

@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;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .rule-card {
    padding: 1rem;
  }
  
  .rule-header h3 {
    font-size: 1rem;
  }
  
  .empty-state {
    padding: 3rem 1.5rem;
  }
  
  .empty-state .empty-icon {
    font-size: 3rem;
  }
}

/* ==================== ANIMATIONS ==================== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.rule-card {
  animation: fadeIn 0.3s ease;
}

.stat-card {
  animation: fadeIn 0.3s ease;
}

/* Stagger animation */
.rule-card:nth-child(1) { animation-delay: 0s; }
.rule-card:nth-child(2) { animation-delay: 0.05s; }
.rule-card:nth-child(3) { animation-delay: 0.1s; }
.rule-card:nth-child(4) { animation-delay: 0.15s; }
.rule-card:nth-child(5) { animation-delay: 0.2s; }
.rule-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; }