@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;800&family=Outfit:wght@400;600;700;800&display=swap');
@import url('/components/cards.css');

:root {
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --card-bg: rgba(17, 24, 39, 0.75);
  --card-border: rgba(255, 255, 255, 0.08);
  --card-hover-border: rgba(99, 102, 241, 0.4);
  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --accent-primary: #6366f1;
  --accent-success: #10b981;
  --accent-warning: #f59e0b;
  --accent-danger: #f43f5e;
  --accent-cyan: #06b6d4;
  --accent-purple: #8b5cf6;

  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.4);

  --font-ar: 'Cairo', system-ui, -apple-system, sans-serif;
  --font-en: 'Outfit', system-ui, -apple-system, sans-serif;
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --card-bg: rgba(255, 255, 255, 0.85);
  --card-border: rgba(226, 232, 240, 0.9);
  --card-hover-border: rgba(99, 102, 241, 0.5);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 20px rgba(0,0,0,0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-ar);
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  direction: rtl;
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
  background-image: 
    radial-gradient(circle at 15% 20%, rgba(99, 102, 241, 0.12) 0%, transparent 45%),
    radial-gradient(circle at 85% 75%, rgba(16, 185, 129, 0.08) 0%, transparent 45%);
}

/* Header Navigation */
header.tier1-navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 32px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--card-border);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 16px;
  text-decoration: none;
}

.brand-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 22px;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.brand-text h1 {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.brand-text p {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-en);
}

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

.dropdown-nav {
  position: relative;
}

.dropdown-select {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text-primary);
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
}

.dropdown-select:hover {
  border-color: var(--accent-primary);
}

.btn-theme-toggle {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text-primary);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-theme-toggle:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.btn-action {
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: var(--accent-primary);
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-action:hover {
  background: var(--accent-primary);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Layout Container */
.container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 32px;
}

/* Hero Section */
.tier1-hero {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 28px 36px;
  margin-bottom: 28px;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.tier1-hero::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -20%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.15), transparent 70%);
  pointer-events: none;
}

.hero-title h2 {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.hero-title p {
  font-size: 14px;
  color: var(--text-secondary);
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--accent-success);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 12px;
}

.hero-score-box {
  text-align: center;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.25);
  padding: 16px 28px;
  border-radius: 16px;
}

.hero-score-val {
  font-size: 38px;
  font-weight: 800;
  color: var(--accent-primary);
  font-family: var(--font-en);
  line-height: 1;
}

.hero-score-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

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

.summary-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 20px 24px;
  transition: all 0.25 ease;
}

.summary-card:hover {
  border-color: var(--card-hover-border);
  transform: translateY(-2px);
}

.card-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.card-title-muted {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
}

.card-icon-pill {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.icon-blue { background: rgba(99, 102, 241, 0.15); color: var(--accent-primary); }
.icon-green { background: rgba(16, 185, 129, 0.15); color: var(--accent-success); }
.icon-yellow { background: rgba(245, 158, 11, 0.15); color: var(--accent-warning); }
.icon-red { background: rgba(244, 63, 94, 0.15); color: var(--accent-danger); }

.card-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  font-family: var(--font-en);
}

.card-subtext {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Domain Section */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.section-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.domains-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 20px;
  margin-bottom: 36px;
}

.domain-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 22px 26px;
  transition: all 0.25s ease;
}

.domain-card:hover {
  border-color: var(--card-hover-border);
  box-shadow: var(--shadow-sm);
}

.domain-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}

.domain-code-badge {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-primary);
  border: 1px solid rgba(99, 102, 241, 0.3);
  padding: 2px 10px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 13px;
}

.domain-name h3 {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
  margin-top: 6px;
}

.domain-name p {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-en);
}

.progress-bar-bg {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
  margin: 12px 0 8px 0;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

/* 12 Standards Grid */
.standards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 24px;
  margin-bottom: 36px;
}

.std-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.25s ease;
  position: relative;
}

.std-card:hover {
  border-color: var(--card-hover-border);
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.std-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.std-num-pill {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(6, 182, 212, 0.2));
  border: 1px solid rgba(99, 102, 241, 0.35);
  color: var(--accent-primary);
  font-size: 18px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-en);
}

.std-title-ar {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
  line-height: 1.4;
}

.std-title-en {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-en);
}

.badge-status {
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
}

.badge-exceeded { background: rgba(16, 185, 129, 0.15); color: var(--accent-success); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-on-track { background: rgba(6, 182, 212, 0.15); color: var(--accent-cyan); border: 1px solid rgba(6, 182, 212, 0.3); }
.badge-attention { background: rgba(244, 63, 94, 0.15); color: var(--accent-danger); border: 1px solid rgba(244, 63, 94, 0.3); }

.std-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-secondary);
  margin: 16px 0 12px 0;
  padding-top: 14px;
  border-top: 1px solid var(--card-border);
}

.btn-view-detail {
  width: 100%;
  padding: 10px 0;
  text-align: center;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: var(--accent-primary);
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.2s ease;
  display: inline-block;
}

.btn-view-detail:hover {
  background: var(--accent-primary);
  color: #ffffff;
}

/* Charts Section */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
  gap: 24px;
  margin-bottom: 36px;
}

.chart-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.chart-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-container-dom {
  width: 100%;
  height: 320px;
}

/* Data Table Styling for Standard Detail Pages */
.table-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 24px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 36px;
}

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

.tier1-table th {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  font-weight: 700;
  padding: 14px 16px;
  border-bottom: 1px solid var(--card-border);
  white-space: nowrap;
}

.tier1-table td {
  padding: 16px;
  border-bottom: 1px solid var(--card-border);
  color: var(--text-primary);
  vertical-align: middle;
}

.tier1-table tr:last-child td {
  border-bottom: none;
}

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

.kpi-code-tag {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-primary);
  border: 1px solid rgba(99, 102, 241, 0.3);
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 800;
  font-family: var(--font-en);
  font-size: 12px;
}

/* Print Styles */
@media print {
  header.tier1-navbar, .btn-action, .btn-theme-toggle, .dropdown-nav {
    display: none !important;
  }
  body {
    background: #ffffff !important;
    color: #000000 !important;
    direction: ltr !important;
  }
  .container {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
  }
  .print-wrapper-rtl {
    direction: rtl !important;
  }
}
