/* Smart Living Platform - Modern Admin Design System (RTL & Dark Theme) */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600;700&family=Vazirmatn:wght@300;400;500;600;700;800;900&display=swap');

:root {
  --font-body: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, monospace;
  --bg-main: #0b0f19;
  --bg-card: #131b2e;
  --bg-card-hover: #1a243d;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #38bdf8;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-glow: rgba(2, 132, 199, 0.3);
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --danger-glow: rgba(239, 68, 68, 0.4);
  --info: #06b6d4;
  --card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --ease-snappy: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-press: cubic-bezier(0.4, 0, 0.2, 1);
  --motion-fast: 0.16s;
  --motion-base: 0.24s;
  --transition: all var(--motion-base) var(--ease-snappy);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-feature-settings: "ss01" 1, "cv01" 1;
}

body {
  font-family: var(--font-body);
  direction: rtl;
  text-align: right;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

/* Layout */
.app-container {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 280px;
  background: #0f172a;
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  z-index: 50;
}

.sidebar-header {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
}

.logo-badge {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 22px;
  font-weight: 800;
  box-shadow: 0 4px 15px var(--primary-glow);
}

.logo-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
}

.logo-subtitle {
  font-size: 11px;
  color: var(--text-muted);
}

.sidebar-menu {
  flex: 1;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  transform: translateX(-4px);
}

.nav-link.active {
  background: linear-gradient(90deg, rgba(2, 132, 199, 0.2), transparent);
  color: #38bdf8;
  border-right: 3px solid #38bdf8;
  font-weight: 600;
}

.nav-link svg {
  width: 20px;
  height: 20px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.2);
}

.user-profile-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-info-text h4 {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

.user-info-text p {
  font-size: 11px;
  color: #38bdf8;
}

.logout-btn {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.logout-btn:hover {
  background: var(--danger-bg);
}

/* Main Content Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.topbar {
  height: 72px;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.page-title h1 {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-simulator {
  background: linear-gradient(135deg, #7c3aed, #9333ea);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
  transition: var(--transition);
}

.btn-simulator:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.5);
}

.btn-simulator:active {
  transform: translateY(1px) scale(0.96);
  transition-duration: 0.08s;
}

.content-body {
  padding: 32px;
  flex: 1;
}

/* Metric Cards Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--card-shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.metric-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.15);
  background: var(--bg-card-hover);
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, #0284c7, transparent);
}

.metric-card.critical::before {
  background: linear-gradient(90deg, #ef4444, transparent);
}

.metric-card.success::before {
  background: linear-gradient(90deg, #10b981, transparent);
}

.metric-info h3 {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.metric-value {
  font-size: 30px;
  font-weight: 900;
  color: #fff;
  letter-spacing: -0.5px;
  font-feature-settings: "ss01" 1, "tnum" 1;
}

.metric-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.metric-icon-box {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.metric-icon-box.blue {
  background: rgba(2, 132, 199, 0.15);
  color: #38bdf8;
}

.metric-icon-box.red {
  background: var(--danger-bg);
  color: #ef4444;
}

.metric-icon-box.green {
  background: var(--success-bg);
  color: #10b981;
}

.metric-icon-box.amber {
  background: var(--warning-bg);
  color: #f59e0b;
}

/* Sections & Tables */
.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  margin-bottom: 32px;
  overflow: hidden;
}

.section-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 13px;
}

.data-table th {
  background: rgba(15, 23, 42, 0.6);
  padding: 14px 20px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
}

.badge-critical {
  background: var(--danger-bg);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-high {
  background: rgba(249, 115, 22, 0.15);
  color: #f97316;
  border: 1px solid rgba(249, 115, 22, 0.3);
}

.badge-medium {
  background: var(--warning-bg);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-success {
  background: var(--success-bg);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-simulated {
  background: rgba(139, 92, 246, 0.15);
  color: #a78bfa;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

/* Action Buttons */
.btn-action {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-action-ack {
  background: rgba(2, 132, 199, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(2, 132, 199, 0.3);
}

.btn-action-ack:hover {
  background: #0284c7;
  color: white;
}

.btn-action-resolve {
  background: var(--success-bg);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.btn-action-resolve:hover {
  background: #10b981;
  color: white;
}

/* Simulator Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  overflow: hidden;
  animation: modalEnter 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalEnter {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

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

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sim-btn-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.sim-btn {
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.03);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  transition: var(--transition);
}

.sim-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: #38bdf8;
  transform: translateY(-2px);
}

.sim-btn.danger:hover {
  border-color: #ef4444;
  background: var(--danger-bg);
}
