/* Wamimy Pulse - Modern Dark Design System */
:root {
  --bg-main: #080c14;
  --bg-card: rgba(15, 23, 42, 0.75);
  --bg-card-hover: rgba(30, 41, 59, 0.85);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: #6366f1;
  
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.35);

  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.3);
  --warning: #f59e0b;
  --warning-glow: rgba(245, 158, 11, 0.3);
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.35);
  --info: #38bdf8;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  
  --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background-image: 
    radial-gradient(circle at 15% 10%, rgba(99, 102, 241, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 85% 60%, rgba(56, 189, 248, 0.08) 0%, transparent 45%);
  background-attachment: fixed;
}

/* NAVBAR */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(8, 12, 20, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 16px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.nav-top-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.nav-quick-actions {
  display: none;
}

.brand-logo-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #6366f1 0%, #3b82f6 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.brand-text h1 {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.brand-text span {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.nav-center-status {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 6px 16px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 600;
  color: #34d399;
}

.nav-center-status.has-incident {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.35);
  color: #f87171;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.desktop-only {
  display: inline-flex;
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  color: #ffffff;
  box-shadow: 0 4px 14px var(--primary-glow);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-outline-danger {
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
}
.btn-outline-danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

/* CONTAINER */
.container {
  max-width: 1360px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* STATS ROW */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  align-items: center;
  gap: 18px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.15);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.blue { background: rgba(56, 189, 248, 0.12); color: #38bdf8; }
.stat-icon.green { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.stat-icon.purple { background: rgba(168, 85, 247, 0.12); color: #a855f7; }
.stat-icon.red { background: rgba(239, 68, 68, 0.12); color: #ef4444; }

.stat-info .stat-value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #ffffff;
  line-height: 1.1;
}

.stat-info .stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
}

/* CONTROLS BAR (SEARCH & FILTERS) */
.controls-bar {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.controls-left {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  flex: 1;
}

.search-input-wrapper {
  position: relative;
  min-width: 260px;
}

.search-input-wrapper input {
  width: 100%;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 9px 14px 9px 36px;
  color: #fff;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

.search-input-wrapper input:focus {
  border-color: var(--primary);
  background: rgba(0, 0, 0, 0.4);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--text-dim);
  pointer-events: none;
}

.filter-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}

.filter-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.filter-tab.active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.select-filter {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  color: var(--text-main);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
}

/* SITES GRID */
.sites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 22px;
}

.site-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  position: relative;
}

.site-card:hover {
  border-color: rgba(255, 255, 255, 0.18);
  transform: translateY(-3px);
  box-shadow: 0 16px 32px -8px rgba(0, 0, 0, 0.5);
}

.site-card.status-down {
  border-color: rgba(239, 68, 68, 0.4);
}

.site-card.status-degraded {
  border-color: rgba(245, 158, 11, 0.4);
}

/* SCREENSHOT PREVIEW HEADER */
.site-preview-header {
  position: relative;
  height: 170px;
  background: #0f172a;
  overflow: hidden;
  border-bottom: 1px solid var(--border-subtle);
}

.site-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
  transition: transform 0.4s ease;
  cursor: pointer;
}

.site-preview-img:hover {
  transform: scale(1.03);
}

.site-preview-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle, #1e293b 0%, #0f172a 100%);
  color: var(--text-dim);
  font-size: 13px;
  gap: 8px;
}

.status-badge-overlay {
  position: absolute;
  top: 12px;
  left: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 700;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.badge-up {
  background: rgba(16, 185, 129, 0.9);
  color: #ffffff;
}

.badge-down {
  background: rgba(239, 68, 68, 0.9);
  color: #ffffff;
}

.badge-degraded {
  background: rgba(245, 158, 11, 0.9);
  color: #ffffff;
}

.badge-checking {
  background: rgba(56, 189, 248, 0.9);
  color: #ffffff;
}

.badge-unknown {
  background: rgba(100, 116, 139, 0.9);
  color: #ffffff;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ffffff;
  display: inline-block;
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.platform-badge-overlay {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 6px;
  text-transform: uppercase;
}

/* CARD CONTENT */
.site-card-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

.site-card-title-group {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.site-name {
  font-size: 17px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 3px;
  word-break: break-word;
}

.site-url-link {
  font-size: 13px;
  color: #60a5fa;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  word-break: break-all;
}

.site-url-link:hover {
  text-decoration: underline;
}

.client-name-tag {
  font-size: 12px;
  color: var(--text-muted);
}

.site-metrics-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px;
  gap: 6px;
  text-align: center;
}

.metric-item .metric-label {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
}

.metric-item .metric-val {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  margin-top: 2px;
}

.error-banner-small {
  background: rgba(239, 68, 68, 0.15);
  border-left: 3px solid #ef4444;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  color: #fca5a5;
  word-break: break-word;
}

/* CARD FOOTER */
.site-card-footer {
  padding: 14px 20px;
  background: rgba(0, 0, 0, 0.15);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.last-check-text {
  font-size: 11px;
  color: var(--text-dim);
}

.card-actions-group {
  display: flex;
  gap: 6px;
}

/* MODALS */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.8);
  transform: translateY(12px) scale(0.98);
  transition: transform 0.2s ease;
}

.modal-card.modal-lg {
  max-width: 860px;
}

.modal-overlay.active .modal-card {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 22px 28px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: var(--transition);
}

.modal-close-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.modal-body {
  padding: 26px 28px;
}

.modal-footer {
  padding: 18px 28px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* FORMS IN MODALS */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 6px;
}

.form-help {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: #ffffff;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

/* TOASTS */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #ffffff;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s ease;
}

.toast.toast-success { border-left: 4px solid var(--success); }
.toast.toast-danger { border-left: 4px solid var(--danger); }
.toast.toast-info { border-left: 4px solid var(--info); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* RESPONSIVE DESIGN FOR TABLETS & SMARTPHONES */
@media (max-width: 992px) {
  .navbar {
    padding: 14px 20px;
    flex-wrap: wrap;
  }
  .nav-center-status {
    order: 3;
    width: 100%;
    justify-content: center;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  /* NAVBAR MOBILE */
  .navbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 14px;
  }

  .nav-top-row {
    width: 100%;
    justify-content: space-between;
  }

  .nav-quick-actions {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .desktop-only {
    display: none !important;
  }

  .btn-icon-only {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    border-radius: var(--radius-md);
  }

  .nav-center-status {
    order: 2;
    width: 100%;
    justify-content: center;
    padding: 5px 12px;
    font-size: 12px;
  }

  .nav-actions {
    order: 3;
    width: 100%;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .nav-actions::-webkit-scrollbar {
    display: none;
  }

  .nav-actions .btn-sm {
    padding: 7px 11px;
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* CONTAINER & SPACING */
  .container {
    padding: 16px 12px 60px 12px;
  }

  /* 2x2 COMPACT STATS GRID ON MOBILE */
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 18px;
  }

  .stat-card {
    padding: 12px 14px;
    gap: 10px;
    border-radius: var(--radius-md);
  }

  .stat-icon {
    width: 36px;
    height: 36px;
    font-size: 18px;
    border-radius: 9px;
  }

  .stat-info .stat-value {
    font-size: 20px;
  }

  .stat-info .stat-label {
    font-size: 10px;
    line-height: 1.2;
    margin-top: 2px;
  }

  /* CONTROLS BAR (SEARCH & FILTERS) */
  .controls-bar {
    padding: 12px;
    gap: 10px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
  }

  .controls-left {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 8px;
  }

  .search-input-wrapper {
    width: 100%;
    min-width: 0;
  }

  .filter-tabs {
    width: 100%;
    display: flex;
    overflow-x: auto;
    padding: 3px;
    gap: 2px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .filter-tabs::-webkit-scrollbar {
    display: none;
  }

  .filter-tab {
    padding: 6px 10px;
    font-size: 11px;
    flex: 1;
    min-width: max-content;
    text-align: center;
  }

  .select-filter {
    width: 100%;
  }

  .controls-right {
    width: 100%;
    text-align: center;
    padding-top: 4px;
    border-top: 1px dashed var(--border-subtle);
  }

  /* SITES GRID & CARDS */
  .sites-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .site-preview-header {
    height: 145px;
  }

  .site-card-body {
    padding: 14px;
    gap: 10px;
  }

  .site-card-title-group {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .site-card-title-group > div:last-child {
    align-items: flex-start !important;
    flex-direction: row !important;
    flex-wrap: wrap;
    gap: 6px !important;
  }

  .site-name {
    font-size: 16px;
  }

  .site-url-link {
    font-size: 12px;
  }

  .site-metrics-row {
    padding: 8px;
    gap: 4px;
  }

  .metric-item .metric-label {
    font-size: 10px;
  }

  .metric-item .metric-val {
    font-size: 13px;
  }

  .site-card-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 14px;
  }

  .last-check-text {
    text-align: center;
    font-size: 11px;
  }

  .card-actions-group {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    width: 100%;
  }

  .card-actions-group .btn-sm {
    min-height: 40px;
    padding: 6px 0;
    justify-content: center;
    font-size: 16px;
    border-radius: 8px;
  }

  /* MODALS MOBILE ERGONOMICS */
  .modal-overlay {
    padding: 10px;
    align-items: center;
  }

  .modal-card {
    max-height: 92vh;
    border-radius: var(--radius-lg);
  }

  .modal-header {
    padding: 14px 18px;
  }

  .modal-title {
    font-size: 16px;
  }

  .modal-body {
    padding: 16px 18px;
  }

  .modal-footer {
    padding: 12px 18px;
    flex-direction: column-reverse;
    gap: 8px;
  }

  .modal-footer .btn {
    width: 100%;
    justify-content: center;
    padding: 10px;
  }

  .form-grid-2 {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Prevent automatic iOS Safari zoom-in on focus by enforcing >= 16px input font size */
  .form-input, .form-select, .form-textarea {
    font-size: 16px !important;
  }

  /* Horizontal scrolling for all modal tables */
  .modal-body table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  #reportPreviewFrame {
    height: 320px;
  }

  /* TOASTS */
  .toast-container {
    left: 14px;
    right: 14px;
    bottom: 14px;
  }

  .toast {
    width: 100%;
    justify-content: center;
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .brand-text h1 {
    font-size: 16px;
  }

  .brand-text span {
    display: none;
  }

  .brand-logo-icon {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .stat-card {
    padding: 10px 12px;
  }

  .stat-icon {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }

  .stat-info .stat-value {
    font-size: 18px;
  }
}
