/* ============================================
   Admin Organizations Page - Elsys CO2 Dizájn
   ============================================ */

/* ==================== 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%);
}

.page-title h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: #0c4a6e;
  margin: 0 0 0.25rem 0;
}

.page-title p {
  color: #0369a1;
  font-size: 0.9rem;
  margin: 0;
  opacity: 0.9;
}

.page-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ==================== 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-label {
  font-size: 0.8rem;
  color: var(--text-secondary, #6b7280);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  text-align: center;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary, #1a1a1a);
  margin: 0;
  line-height: 1.2;
  text-align: center;
}

/* ==================== CARD CONTAINER - Elsys stílus ==================== */
.card {
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius-lg, 12px);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  margin-bottom: 1.5rem;
  position: relative;
  transition: all 0.25s ease;
}

.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;
}

.card:hover::before {
  opacity: 1;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  background: var(--bg-secondary, #f9fafb);
  border-bottom: 1px solid var(--border, #e5e7eb);
  flex-wrap: wrap;
  gap: 1rem;
}

.card-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text-primary, #1a1a1a);
  font-weight: 600;
}

.card-filters {
  display: flex;
  gap: 0.75rem;
  flex: 1;
  max-width: 500px;
  margin-left: auto;
  position: relative;
}

.card-filters .form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius-md, 10px);
  color: var(--text-primary, #1a1a1a);
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.card-filters .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);
}

.card-filters .form-control::placeholder {
  color: var(--text-tertiary, #9ca3af);
}

.card-body {
  padding: 0;
}

/* ==================== TABLE - Elsys stílus ==================== */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 0 0 var(--radius-lg, 12px) var(--radius-lg, 12px);
}

.table {
  width: 100%;
  min-width: 1000px;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.table thead {
  background: var(--bg-secondary, #f9fafb);
  border-bottom: 2px solid var(--border, #e5e7eb);
}

.table th {
  padding: 1rem 1.25rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary, #1a1a1a);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.table tbody tr {
  border-bottom: 1px solid var(--border, #e5e7eb);
  transition: all 0.2s ease;
  position: relative;
}

.table tbody tr::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent-primary, #3b82f6);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.table tbody tr:hover {
  background: var(--bg-hover, #f3f4f6);
}

.table tbody tr:hover::before {
  opacity: 1;
}

.table td {
  padding: 1rem 1.25rem;
  color: var(--text-secondary, #6b7280);
  vertical-align: middle;
}

/* Eszközök/Felhasználók oszlopok */
.table td:nth-child(5),
.table td:nth-child(6) {
  text-align: center;
  padding: 0.75rem;
}

/* Státusz oszlop */
.table td:nth-child(7) {
  text-align: center;
}

/* Műveletek oszlop */
.table td:last-child {
  text-align: right;
  white-space: nowrap;
}

.table tbody tr:last-child {
  border-bottom: none;
}

.table td strong {
  color: var(--text-primary, #1a1a1a);
  font-weight: 600;
}

/* ==================== BADGES - Elsys stílus ==================== */
.badge,
.role-badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.375rem 0.875rem;
  border-radius: var(--radius-sm, 8px);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

/* Status badges - Admin Organizations */
.badge-success,
.status-badge.active {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success, #10b981);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-danger,
.status-badge.inactive {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger, #ef4444);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-secondary {
  background: rgba(107, 114, 128, 0.15);
  color: var(--text-tertiary, #9ca3af);
  border: 1px solid rgba(107, 114, 128, 0.3);
}

/* Role badges - Admin Users kompatibilitás */
.role-badge.admin {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger, #ef4444);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.role-badge.tenant {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-primary, #3b82f6);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.role-badge.user {
  background: rgba(107, 114, 128, 0.15);
  color: var(--text-tertiary, #9ca3af);
  border: 1px solid rgba(107, 114, 128, 0.3);
}

/* Status dot animáció (ha van) */
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-badge.active .status-dot,
.badge-success .status-dot {
  animation: online-pulse 2s ease-in-out infinite;
  box-shadow: 0 0 8px currentColor;
}

@keyframes online-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* ==================== ACTION BUTTONS - Elsys stílus ==================== */
.action-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-icon {
  min-width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0 0.625rem;
  background: var(--bg-secondary, #f9fafb);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius-sm, 8px);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1rem;
  color: var(--text-secondary, #6b7280);
  white-space: nowrap;
  font-weight: 600;
}

/* Icon + Count gombok (pl. 👥 3) */
.btn-icon span {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary, #1a1a1a);
}

.btn-icon:hover {
  background: var(--accent-primary, #3b82f6);
  border-color: var(--accent-primary, #3b82f6);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

.btn-icon:hover span {
  color: white;
}

.btn-icon-danger:hover,
.btn-danger:hover {
  background: var(--danger, #ef4444);
  border-color: var(--danger, #ef4444);
  box-shadow: 0 4px 8px rgba(239, 68, 68, 0.3);
}

/* Csak icon gombok (action-buttons-ban) */
.action-buttons .btn-icon {
  min-width: 36px;
  width: 36px;
  padding: 0;
}

.action-buttons .btn-icon span {
  display: none;
}

/* ==================== MODAL - Elsys stílus ==================== */
.config-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 10000;
  align-items: center;
  justify-content: center;
}

.modal-content {
  position: relative;
  background: var(--bg-card, #ffffff);
  padding: 2rem;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius-xl, 16px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-content .close {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary, #f9fafb);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius-sm, 8px);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1.5rem;
  color: var(--text-secondary, #6b7280);
  line-height: 1;
}

.modal-content .close:hover {
  background: var(--danger, #ef4444);
  border-color: var(--danger, #ef4444);
  color: white;
  transform: rotate(90deg);
}

.modal-content h2 {
  margin: 0 0 1.5rem 0;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border, #e5e7eb);
  font-size: 1.5rem;
  color: var(--text-primary, #1a1a1a);
  font-weight: 700;
}

/* ==================== FORM GROUPS - 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::placeholder {
  color: var(--text-tertiary, #9ca3af);
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
}

.form-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent-primary, #3b82f6);
  margin-right: 0.5rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-weight: 500;
}

.form-group small {
  display: block;
  color: var(--text-tertiary, #9ca3af);
  font-size: 0.8rem;
  margin-top: 0.375rem;
}

/* ==================== MULTI-SELECT LIST ==================== */
.multi-select-list {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius-md, 10px);
  padding: 0.75rem;
  background: var(--bg-secondary, #f9fafb);
  scrollbar-width: thin;
  scrollbar-color: var(--border, #e5e7eb) transparent;
}

.multi-select-list::-webkit-scrollbar {
  width: 6px;
}

.multi-select-list::-webkit-scrollbar-track {
  background: transparent;
}

.multi-select-list::-webkit-scrollbar-thumb {
  background: var(--border, #e5e7eb);
  border-radius: 3px;
}

.multi-select-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem;
  border-radius: var(--radius-md, 10px);
  transition: all 0.2s ease;
  margin-bottom: 0.5rem;
  border: 1px solid var(--border, #e5e7eb);
  background: var(--bg-card, #ffffff);
  cursor: pointer;
}

.multi-select-item:hover {
  background: var(--bg-hover, #f3f4f6);
  border-color: var(--accent-primary, #3b82f6);
  transform: translateX(4px);
}

.multi-select-item:last-child {
  margin-bottom: 0;
}

.multi-select-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent-primary, #3b82f6);
  margin: 0;
}

.multi-select-item label {
  flex: 1;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-primary, #1a1a1a);
  margin: 0 !important;
  display: block !important;
}

.multi-select-item .item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.multi-select-item .item-name {
  font-weight: 600;
  color: var(--text-primary, #1a1a1a);
}

.multi-select-item .item-detail {
  font-size: 0.85rem;
  color: var(--text-secondary, #6b7280);
}

/* ==================== 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;
}

.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-overlay p {
  color: var(--text-secondary, #6b7280);
  font-size: 0.95rem;
  font-weight: 500;
}

/* ==================== NO DATA / EMPTY STATE ==================== */
.no-data {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-secondary, #6b7280);
}

.no-data .empty-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.4;
  filter: grayscale(1);
}

.no-data h3 {
  color: var(--text-primary, #1a1a1a);
  margin: 0 0 0.5rem 0;
}

/* ==================== DARK MODE - Elsys stílus ==================== */
[data-theme="dark"] .page-header {
  background: linear-gradient(135deg, #1e3a5f 0%, #1e40af 100%);
  border-color: #3b82f6;
}

[data-theme="dark"] .page-title h1 {
  color: #e0f2fe;
}

[data-theme="dark"] .page-title p {
  color: #93c5fd;
}

[data-theme="dark"] .stat-card,
[data-theme="dark"] .card {
  background: var(--bg-card, #1f2937);
  border-color: var(--border, #374151);
}

[data-theme="dark"] .card-header,
[data-theme="dark"] .table thead {
  background: var(--bg-secondary, #111827);
  border-color: var(--border, #374151);
}

[data-theme="dark"] .table tbody tr {
  background: var(--bg-card, #1f2937);
  border-color: var(--border, #374151);
}

[data-theme="dark"] .table tbody tr:hover {
  background: var(--bg-hover, #374151);
}

[data-theme="dark"] .table td {
  color: var(--text-secondary, #9ca3af);
}

[data-theme="dark"] .table td strong {
  color: var(--text-primary, #f9fafb);
}

[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"] .modal-content {
  background: var(--bg-card, #1f2937);
  border-color: var(--border, #374151);
}

[data-theme="dark"] .loading-overlay {
  background: rgba(15, 23, 42, 0.95);
}

[data-theme="dark"] .multi-select-list {
  background: var(--bg-secondary, #111827);
}

[data-theme="dark"] .multi-select-item {
  background: var(--bg-card, #1f2937);
  border-color: var(--border, #374151);
}

[data-theme="dark"] .multi-select-item:hover {
  background: var(--bg-hover, #374151);
}

[data-theme="dark"] .btn-icon {
  background: var(--bg-secondary, #111827);
  border-color: var(--border, #374151);
  color: var(--text-secondary, #9ca3af);
}

[data-theme="dark"] .btn-icon span {
  color: var(--text-primary, #f9fafb);
}

[data-theme="dark"] .btn-icon:hover span {
  color: white;
}

/* ==================== RESPONSIVE - Mobile First ==================== */
@media (max-width: 968px) {
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 1.25rem;
    padding: 1.25rem;
  }
  
  .page-title h1 {
    font-size: 1.5rem;
  }
  
  .page-actions {
    width: 100%;
  }
  
  .page-actions .btn {
    flex: 1;
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
  
  .stat-card {
    padding: 1.25rem 1rem;
  }
  
  .stat-icon {
    width: 40px;
    height: 40px;
    font-size: 1.25rem;
  }
  
  .stat-value {
    font-size: 1.5rem;
  }
  
  .card-header {
    flex-direction: column;
    align-items: stretch;
    padding: 1rem;
  }
  
  .card-filters {
    max-width: none;
    margin-left: 0;
  }
  
  .table-responsive {
    margin: 0;
    border-radius: 0;
  }
}

@media (max-width: 480px) {
  .page-header {
    padding: 1rem;
    border-radius: 12px;
  }
  
  .page-title h1 {
    font-size: 1.25rem;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .stat-value {
    font-size: 1.25rem;
  }
  
  .stat-label {
    font-size: 0.75rem;
  }
  
  .table th,
  .table td {
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
  }
  
  .action-buttons {
    gap: 0.375rem;
  }
  
  .btn-icon {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }
  
  .modal-content {
    width: 95%;
    padding: 1.5rem;
  }
  
  .modal-content h2 {
    font-size: 1.25rem;
  }
}

/* ==================== ANIMATIONS ==================== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stat-card,
.card {
  animation: fadeIn 0.3s ease;
}

/* Stagger animation */
.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; }