/* ============================================
   نظام حساب فروقات الإجازات والتعويضات
   Saudi HR Vacation Differences Calculator
   Professional Saudi Government Style
   ============================================ */

/* ---------- Google Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800;900&display=swap');

/* ---------- CSS Custom Properties ---------- */
:root {
  /* Saudi Government Colors */
  --saudi-green: #006C35;
  --saudi-green-dark: #004D27;
  --saudi-green-light: #00894A;
  --saudi-green-pale: #E8F5EC;
  --saudi-green-soft: #D0EBDA;

  /* Neutrals */
  --white: #FFFFFF;
  --gray-50: #F8FAFB;
  --gray-100: #F1F4F6;
  --gray-200: #E4E8EC;
  --gray-300: #CDD3D9;
  --gray-400: #9CA5AE;
  --gray-500: #6B7580;
  --gray-600: #4A5460;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;

  /* Accent */
  --gold: #D4A843;
  --gold-light: #F5E6B8;
  --blue-info: #2563EB;
  --blue-light: #DBEAFE;
  --red-error: #DC2626;
  --red-light: #FEE2E2;
  --orange-warn: #EA580C;
  --orange-light: #FFF7ED;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 40px rgba(0,0,0,0.1), 0 8px 16px rgba(0,0,0,0.04);
  --shadow-green: 0 4px 14px rgba(0,108,53,0.25);

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.25s ease;
  --transition-slow: 0.4s ease;
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: 'Tajawal', sans-serif;
  direction: rtl;
  text-align: right;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.7;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--gray-100);
}
::-webkit-scrollbar-thumb {
  background: var(--saudi-green);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--saudi-green-dark);
}

/* ---------- Background Pattern ---------- */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image:
    radial-gradient(circle at 20% 50%, rgba(0,108,53,0.03) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(0,108,53,0.04) 0%, transparent 50%),
    radial-gradient(circle at 50% 80%, rgba(212,168,67,0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ---------- Header ---------- */
.app-header {
  background: linear-gradient(135deg, var(--saudi-green-dark) 0%, var(--saudi-green) 50%, var(--saudi-green-light) 100%);
  color: var(--white);
  padding: 0;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-xl);
}

.app-header::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 30px,
    rgba(255,255,255,0.015) 30px,
    rgba(255,255,255,0.015) 60px
  );
  animation: headerPattern 60s linear infinite;
}

@keyframes headerPattern {
  0% { transform: translate(0, 0); }
  100% { transform: translate(60px, 60px); }
}

.header-content {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
  text-align: center;
}

/* ---------- Header Logo ---------- */
.header-logo-wrap {
  margin: 0 auto 18px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.header-msd-logo {
  height: 95px;
  max-width: 250px;
  object-fit: contain;
  background: transparent;
  border-radius: 50%;
  padding: 0;
  filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.8)) drop-shadow(0 0 30px rgba(255, 255, 255, 0.4));
  animation: intense-pulse-glow 2.5s ease-in-out infinite;
  transition: transform 0.3s ease;
}
.header-msd-logo:hover {
  transform: scale(1.08) translateY(-2px);
}

@keyframes intense-pulse-glow {
  0%, 100% { filter: drop-shadow(0 0 15px rgba(255,255,255,0.6)); }
  50% { filter: drop-shadow(0 0 30px rgba(255,255,255,0.95)) drop-shadow(0 0 45px rgba(255,255,255,0.6)); }
}

.header-title {
  font-size: 1.85rem;
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.header-subtitle {
  font-size: 1rem;
  font-weight: 400;
  opacity: 0.85;
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ---------- Navigation Tabs ---------- */
.nav-tabs {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.nav-tabs-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  overflow-x: auto;
  padding: 0 16px;
  gap: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.nav-tabs-inner::-webkit-scrollbar {
  display: none;
}

.nav-tab {
  padding: 14px 20px;
  font-family: 'Tajawal', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-500);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition-base);
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-tab:hover {
  color: var(--saudi-green);
  background: var(--saudi-green-pale);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.nav-tab.active {
  color: var(--saudi-green);
  border-bottom-color: var(--saudi-green);
}

.nav-tab .tab-icon {
  font-size: 1.1rem;
}

/* ---------- Main Container ---------- */
.main-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px;
  position: relative;
  z-index: 1;
}

/* ---------- Sections ---------- */
.section {
  display: none;
  animation: fadeSlideIn 0.4s ease;
}

.section.active {
  display: block;
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Cards ---------- */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
  overflow: hidden;
  transition: var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.card-header {
  background: linear-gradient(135deg, var(--saudi-green-pale) 0%, var(--white) 100%);
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-header-icon {
  width: 42px;
  height: 42px;
  background: var(--saudi-green);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 1.2rem;
  flex-shrink: 0;
  box-shadow: var(--shadow-green);
}

.card-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--gray-800);
}

.card-header p {
  font-size: 0.85rem;
  color: var(--gray-500);
  margin-top: 2px;
}

.card-body {
  padding: 24px;
}

/* ---------- Form Styles ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.form-group label .label-icon {
  color: var(--saudi-green);
  font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group .readonly-div {
  font-family: 'Tajawal', sans-serif;
  font-size: 0.95rem;
  padding: 12px 16px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: var(--gray-50);
  color: var(--gray-800);
  direction: rtl;
  transition: var(--transition-base);
  outline: none;
}

.form-group .readonly-div {
  display: flex;
  align-items: center;
  min-height: 48px;
  background: var(--gray-100);
  cursor: default;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--saudi-green);
  background: var(--white);
  box-shadow: 0 0 0 4px rgba(0,108,53,0.08);
}

.form-group input::placeholder {
  color: var(--gray-400);
}

.form-group input.error {
  border-color: var(--red-error);
  background: var(--red-light);
}

/* ---------- Salary Summary Pill ---------- */
.salary-summary {
  background: linear-gradient(135deg, var(--saudi-green) 0%, var(--saudi-green-light) 100%);
  color: var(--white);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  box-shadow: var(--shadow-green);
}

.salary-item {
  text-align: center;
}

.salary-item .label {
  font-size: 0.8rem;
  opacity: 0.85;
  margin-bottom: 4px;
}

.salary-item .value {
  font-size: 1.4rem;
  font-weight: 800;
}

/* ---------- Net Salary Item ---------- */
.salary-item-net {
  background: rgba(212,168,67,0.18);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  border: 1px solid rgba(212,168,67,0.4);
}
.salary-item-net .value {
  color: #FFE07A;
}

/* ---------- Calculation Method Panel ---------- */
.calc-method-panel {
  margin-top: 20px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.calc-method-header {
  background: linear-gradient(135deg, var(--saudi-green-pale) 0%, #f0f9f4 100%);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--saudi-green-dark);
  border-bottom: 1px solid var(--gray-200);
  user-select: none;
  transition: background var(--transition-fast);
}
.calc-method-header:hover {
  background: var(--saudi-green-soft);
}
.calc-method-toggle {
  font-size: 0.75rem;
  opacity: 0.7;
}
.calc-method-body {
  padding: 0;
  overflow-x: auto;
}
.calc-method-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  direction: rtl;
}
.calc-method-table thead th {
  background: var(--saudi-green);
  color: var(--white);
  padding: 10px 14px;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}
.calc-method-table tbody tr {
  border-bottom: 1px solid var(--gray-100);
  transition: background var(--transition-fast);
}
.calc-method-table tbody tr:hover {
  background: var(--gray-50);
}
.calc-method-table td {
  padding: 9px 14px;
  vertical-align: middle;
}
.cmr-val {
  font-weight: 700;
  color: var(--gray-800);
  white-space: nowrap;
  text-align: left;
  direction: ltr;
}
.cmr-formula {
  color: var(--gray-600);
  font-size: 0.82rem;
}
.cmr-basic {
  background: #f0faf5;
}
.cmr-basic td:first-child {
  font-weight: 700;
  color: var(--saudi-green-dark);
}
.cmr-info {
  background: #fffbea;
}
.cmr-first {
  color: var(--gold) !important;
}
.cmr-allowance td:first-child {
  color: var(--gray-700);
}
.cmr-divider td {
  padding: 3px 0;
  background: var(--gray-100);
}
.cmr-total {
  background: #D1FAE5;
  font-weight: 700;
  border-top: 2px solid #006C35;
}
.cmr-total td {
  color: #065F46 !important;
  font-weight: 700;
}
.cmr-total .cmr-val {
  color: #065F46;
  font-size: 1rem;
}
.cmr-deduct {
  background: #fff5f5;
}
.cmr-neg {
  color: var(--red-error) !important;
}
.cmr-net {
  background: linear-gradient(90deg, #004D27 0%, #006C35 100%);
}
.cmr-net td {
  color: var(--white) !important;
  font-weight: 700;
  padding: 12px 14px;
}
.cmr-net:hover td {
  color: #FFE07A !important;
  text-shadow: 0 0 8px rgba(255,224,122,0.6);
}
.cmr-net-val {
  color: #FFE07A !important;
  font-size: 1.1rem;
}

/* ---------- Allowances ---------- */
.allowance-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.allowance-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  animation: fadeSlideIn 0.3s ease;
}

.allowance-row .form-group {
  margin-bottom: 0;
}

.allowance-row .form-group label {
  font-size: 0.8rem;
}

.btn-remove-allowance {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 2px solid var(--red-light);
  background: var(--white);
  color: var(--red-error);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
  align-self: end;
  margin-bottom: 2px;
}

.btn-remove-allowance:hover {
  background: var(--red-error);
  color: var(--white);
  border-color: var(--red-error);
}

/* ---------- Buttons ---------- */
.btn {
  font-family: 'Tajawal', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 12px 28px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition-base);
  outline: none;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--saudi-green) 0%, var(--saudi-green-light) 100%);
  color: var(--white);
  box-shadow: var(--shadow-green);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,108,53,0.35);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--white);
  color: var(--saudi-green);
  border: 2px solid var(--saudi-green);
}

.btn-secondary:hover {
  background: var(--saudi-green-pale);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--gray-600);
  border: 2px solid var(--gray-300);
}

.btn-outline:hover {
  border-color: var(--saudi-green);
  color: var(--saudi-green);
  background: var(--saudi-green-pale);
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold) 0%, #C49B38 100%);
  color: var(--white);
}

.btn-gold:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(212,168,67,0.35);
}

.btn-danger {
  background: var(--red-error);
  color: var(--white);
}

.btn-danger:hover {
  background: #B91C1C;
  transform: translateY(-1px);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.85rem;
}

.btn-lg {
  padding: 16px 36px;
  font-size: 1.05rem;
}

.btn-block {
  width: 100%;
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

/* ---------- Results ---------- */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.result-card {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  transition: var(--transition-base);
}

.result-card:hover {
  border-color: var(--saudi-green);
  box-shadow: var(--shadow-md);
}

.result-card .result-label {
  font-size: 0.82rem;
  color: var(--gray-500);
  font-weight: 500;
  margin-bottom: 8px;
}

.result-card .result-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--gray-800);
}

.result-card .result-unit {
  font-size: 0.75rem;
  color: var(--gray-400);
  margin-top: 4px;
}

.result-card.highlight {
  background: linear-gradient(135deg, var(--saudi-green) 0%, var(--saudi-green-light) 100%);
  border-color: var(--saudi-green);
  box-shadow: var(--shadow-green);
}

.result-card.highlight .result-label {
  color: rgba(255,255,255,0.8);
}

.result-card.highlight .result-value {
  color: var(--white);
}

.result-card.highlight .result-unit {
  color: rgba(255,255,255,0.7);
}

.result-card.warning {
  background: var(--orange-light);
  border-color: var(--orange-warn);
}

.result-card.warning .result-value {
  color: var(--orange-warn);
}

/* ---------- Alert Messages ---------- */
.alert {
  padding: 14px 20px;
  border-radius: var(--radius-md);
  margin: 16px 0;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 0.9rem;
  animation: fadeSlideIn 0.3s ease;
}

.alert-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.alert-success {
  background: var(--saudi-green-pale);
  border: 1px solid var(--saudi-green-soft);
  color: var(--saudi-green-dark);
}

.alert-warning {
  background: var(--orange-light);
  border: 1px solid #FDBA74;
  color: #9A3412;
}

.alert-error {
  background: var(--red-light);
  border: 1px solid #FCA5A5;
  color: #991B1B;
}

.alert-info {
  background: var(--blue-light);
  border: 1px solid #93C5FD;
  color: #1E40AF;
}

/* ---------- History Table ---------- */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
}

.data-table thead th {
  background: var(--saudi-green);
  color: var(--white);
  padding: 14px 16px;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.data-table thead th:first-child {
  border-radius: 0 var(--radius-md) 0 0;
}

.data-table thead th:last-child {
  border-radius: var(--radius-md) 0 0 0;
}

.data-table tbody tr {
  transition: var(--transition-fast);
}

.data-table tbody tr:hover {
  background: var(--saudi-green-pale);
}

.data-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-200);
  vertical-align: middle;
}

.data-table .actions {
  display: flex;
  gap: 8px;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-400);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 1rem;
  margin-bottom: 8px;
}

/* ---------- Modal / Report Preview ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
  padding: 20px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--white);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

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

.modal-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
}

.modal-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--gray-100);
  color: var(--gray-600);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.modal-close:hover {
  background: var(--red-light);
  color: var(--red-error);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* ---------- Report Print Styles ---------- */
.report-content {
  padding: 20px;
}

.report-header-block {
  text-align: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 3px solid var(--saudi-green);
}

.report-header-block h2 {
  font-size: 1.3rem;
  color: var(--saudi-green);
  margin-bottom: 4px;
}

.report-header-block p {
  font-size: 0.85rem;
  color: var(--gray-500);
}

.report-section {
  margin-bottom: 24px;
}

.report-section h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--saudi-green);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--gray-200);
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.report-table td,
.report-table th {
  padding: 10px 14px;
  border: 1px solid var(--gray-200);
  text-align: right;
}

.report-table th {
  background: var(--saudi-green-pale);
  font-weight: 600;
  color: var(--gray-700);
}

.report-highlight {
  background: var(--saudi-green) !important;
  color: var(--white) !important;
  font-weight: 700;
  font-size: 1.05rem;
}

/* ---------- Chart Container ---------- */
.chart-container {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-top: 20px;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

/* ---------- Footer ---------- */
.app-footer {
  background: var(--gray-800);
  color: var(--gray-400);
  text-align: center;
  padding: 32px 24px;
  margin-top: 40px;
  position: relative;
}

.app-footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--saudi-green), var(--gold), var(--saudi-green));
}

.footer-label {
  font-size: 0.8rem;
  opacity: 0.7;
  margin-bottom: 6px;
}

.footer-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 4px;
}

.footer-phone {
  font-size: 0.95rem;
  color: var(--gold);
  direction: ltr;
  unicode-bidi: isolate;
}

.footer-org {
  font-size: 0.9rem;
  color: var(--gray-300);
  margin-bottom: 4px;
  font-weight: 500;
}

.footer-copyright {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-top: 8px;
  opacity: 0.7;
}

/* Empty grade cells (nhayet almarbout) */
.empty-grade {
  color: var(--gray-300) !important;
  background: var(--gray-100) !important;
  font-weight: 400 !important;
}

/* Grade count column */
.grade-count-col {
  background: #FEF3C7 !important;
  font-weight: 800 !important;
  color: #92400E !important;
  min-width: 40px;
}

/* ---------- Toast Notification ---------- */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--gray-800);
  color: var(--white);
  padding: 14px 24px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  max-width: 400px;
}

.toast.success {
  background: var(--saudi-green);
}

.toast.error {
  background: var(--red-error);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; transform: translateY(-20px); }
}

/* ---------- Responsive ---------- */

/* Tablets */
@media (max-width: 768px) {
  .header-title {
    font-size: 1.25rem;
  }

  .header-subtitle {
    font-size: 0.82rem;
  }

  .header-emblem {
    width: 56px;
    height: 56px;
  }

  .header-emblem svg {
    width: 30px;
    height: 30px;
  }

  .header-content {
    padding: 20px 16px;
  }

  .card-body {
    padding: 16px;
  }

  .card-header {
    padding: 14px 16px;
  }

  .card-header h2 {
    font-size: 1rem;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .allowance-row {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .allowance-row .form-group:first-child {
    grid-column: 1 / -1;
  }

  .results-grid {
    grid-template-columns: 1fr 1fr;
  }

  .btn-group {
    flex-direction: column;
  }

  .btn-group .btn {
    width: 100%;
  }

  .salary-summary {
    grid-template-columns: 1fr 1fr;
    padding: 16px;
  }

  .nav-tab {
    padding: 10px 12px;
    font-size: 0.78rem;
    gap: 4px;
  }

  .nav-tab .tab-icon {
    font-size: 0.95rem;
  }

  .nav-tabs-inner {
    padding: 0 8px;
    gap: 2px;
  }

  .salary-item .value {
    font-size: 1.15rem;
  }

  .salary-item .label {
    font-size: 0.72rem;
  }

  .result-card .result-value {
    font-size: 1.2rem;
  }

  .result-card {
    padding: 14px;
  }

  .modal {
    max-height: 85vh;
  }

  .modal-overlay {
    padding: 10px;
  }

  .scale-legend {
    font-size: 0.78rem;
    padding: 8px 12px;
  }
}

/* Small phones */
@media (max-width: 480px) {
  html {
    font-size: 14px;
  }

  .header-content {
    padding: 18px 12px;
  }

  .header-title {
    font-size: 1.1rem;
    letter-spacing: 0;
  }

  .header-subtitle {
    font-size: 0.75rem;
  }

  .header-emblem {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
  }

  .header-emblem svg {
    width: 26px;
    height: 26px;
  }

  .main-container {
    padding: 12px 8px;
  }

  .card {
    margin-bottom: 14px;
    border-radius: var(--radius-md);
  }

  .card-body {
    padding: 12px;
  }

  .card-header {
    padding: 12px;
    gap: 8px;
  }

  .card-header-icon {
    width: 34px;
    height: 34px;
    font-size: 1rem;
  }

  .card-header h2 {
    font-size: 0.92rem;
  }

  .card-header p {
    font-size: 0.78rem;
  }

  .form-group label {
    font-size: 0.82rem;
  }

  .form-group input,
  .form-group select {
    padding: 10px 12px;
    font-size: 0.88rem;
  }

  .allowance-row {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .results-grid {
    grid-template-columns: 1fr;
  }

  .salary-summary {
    grid-template-columns: 1fr;
    padding: 14px;
    gap: 10px;
  }

  .salary-item .value {
    font-size: 1.1rem;
  }

  .nav-tab {
    padding: 10px 8px;
    font-size: 0.72rem;
    gap: 3px;
  }

  .nav-tab .tab-icon {
    font-size: 0.85rem;
  }

  .nav-tab .tab-text {
    display: none;
  }

  .btn {
    padding: 10px 20px;
    font-size: 0.88rem;
  }

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

  .result-card {
    padding: 12px;
  }

  .result-card .result-value {
    font-size: 1.1rem;
  }

  .result-card .result-label {
    font-size: 0.75rem;
  }

  .modal {
    border-radius: var(--radius-md);
    max-height: 90vh;
  }

  .modal-header {
    padding: 16px;
  }

  .modal-body {
    padding: 16px;
  }

  .modal-footer {
    padding: 12px 16px;
    flex-wrap: wrap;
  }

  .modal-footer .btn {
    flex: 1;
    min-width: 100px;
  }

  .report-content {
    padding: 12px;
  }

  .report-header-block h2 {
    font-size: 1.05rem;
  }

  .report-table td,
  .report-table th {
    padding: 8px 10px;
    font-size: 0.82rem;
  }

  .data-table tbody td {
    padding: 8px 10px;
  }

  .data-table thead th {
    padding: 10px 10px;
    font-size: 0.8rem;
  }

  .toast {
    max-width: 300px;
    font-size: 0.82rem;
    padding: 10px 16px;
  }

  .alert {
    padding: 10px 14px;
    font-size: 0.82rem;
  }

  .chart-container {
    max-width: 100%;
  }

  .app-footer {
    padding: 24px 16px;
  }

  .footer-name {
    font-size: 0.95rem;
  }

  .footer-phone {
    font-size: 0.85rem;
  }

  .scale-legend {
    font-size: 0.72rem;
    padding: 6px 10px;
  }
}

/* Extra small phones (320px) */
@media (max-width: 360px) {
  html {
    font-size: 13px;
  }

  .header-title {
    font-size: 1rem;
  }

  .header-subtitle {
    font-size: 0.72rem;
  }

  .header-emblem {
    width: 42px;
    height: 42px;
  }

  .header-emblem svg {
    width: 22px;
    height: 22px;
  }

  .nav-tab {
    padding: 8px 6px;
    font-size: 0.68rem;
  }

  .card-body {
    padding: 10px;
  }

  .main-container {
    padding: 8px 6px;
  }

  .btn {
    padding: 8px 14px;
    font-size: 0.82rem;
  }

  .salary-summary {
    padding: 10px;
    gap: 8px;
  }

  .salary-item .value {
    font-size: 0.95rem;
  }
}

/* ---------- Print ---------- */
@media print {
  body {
    background: white;
    font-size: 12pt;
  }

  body::before,
  .nav-tabs,
  .app-header::before,
  .btn-group,
  .btn,
  .toast-container,
  .modal-overlay {
    display: none !important;
  }

  .app-header {
    background: white !important;
    color: var(--gray-800) !important;
    box-shadow: none !important;
    border-bottom: 3px solid var(--saudi-green);
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .header-emblem {
    background: var(--saudi-green) !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .header-title {
    color: var(--saudi-green) !important;
    text-shadow: none;
  }

  .header-subtitle {
    color: var(--gray-600) !important;
  }

  .section {
    display: block !important;
    page-break-inside: avoid;
  }

  .card {
    box-shadow: none !important;
    border: 1px solid var(--gray-300);
    break-inside: avoid;
  }

  .app-footer {
    background: white !important;
    color: var(--gray-800) !important;
    border-top: 2px solid var(--gray-300);
  }

  .app-footer::before {
    display: none;
  }

  .footer-name {
    color: var(--gray-800) !important;
  }

  .footer-phone {
    color: var(--saudi-green) !important;
  }
}

/* ---------- Riyal SVG Icon ---------- */
.riyal-icon {
  height: 16px;
  width: auto;
  vertical-align: middle;
  filter: brightness(0) saturate(100%) invert(26%) sepia(92%) saturate(1200%) hue-rotate(140deg) brightness(95%) contrast(101%);
}

.riyal-icon-white {
  height: 18px;
  width: auto;
  vertical-align: middle;
  filter: brightness(0) invert(1);
}

.riyal-icon-inline {
  height: 0.85em;
  width: auto;
  vertical-align: middle;
}

.result-card.highlight .riyal-icon-inline {
  filter: brightness(0) invert(1);
}

/* ---------- Salary Scale Tables ---------- */
.salary-scale-table {
  font-size: 0.78rem !important;
}

.salary-scale-table thead th {
  padding: 10px 8px !important;
  font-size: 0.75rem;
}

.salary-scale-table tbody td {
  padding: 8px 6px !important;
  text-align: center;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.salary-scale-table tbody tr:nth-child(even) {
  background: var(--gray-50);
}

.salary-scale-table tbody td:first-child,
.salary-scale-table tbody td:nth-child(2) {
  text-align: right;
  font-weight: 600;
  background: var(--saudi-green-pale);
}

/* Transport allowance column highlight */
.transport-col {
  background: var(--gold-light) !important;
  font-weight: 700 !important;
  color: var(--gray-800) !important;
}

.salary-scale-table thead th:nth-child(3) {
  background: #005528 !important;
}

/* Scale legend info banner */
.scale-legend {
  background: linear-gradient(135deg, var(--blue-light), #F0F7FF);
  border: 1px solid #93C5FD;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: #1E40AF;
  font-weight: 600;
  line-height: 1.6;
}

/* ---------- Read-only input style ---------- */
.form-group input[readonly] {
  background: var(--gray-100);
  border-color: var(--gray-200);
  color: var(--saudi-green);
  font-weight: 700;
}

/* ---------- Utility ---------- */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.text-green {
  color: var(--saudi-green);
}

.text-gold {
  color: var(--gold);
}

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.divider {
  height: 1px;
  background: var(--gray-200);
  margin: 24px 0;
}

/* ─────────────────────────────────────────
   Footer MsD
───────────────────────────────────────── */
.app-footer {
  background: linear-gradient(135deg, var(--saudi-green-dark) 0%, var(--saudi-green) 100%);
  color: rgba(255,255,255,0.9);
  text-align: center;
  padding: 24px 20px;
  margin-top: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.footer-logo-wrap { margin-bottom: 4px; }

.footer-msd-logo {
  height: 60px;
  object-fit: contain;
  background: transparent;
  border-radius: 50%;
  padding: 0;
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.7));
  animation: intense-pulse-glow 2.5s ease-in-out infinite;
  transition: transform 0.3s ease;
}
.footer-msd-logo:hover {
  transform: scale(1.1);
}

.footer-tagline {
  font-size: 0.82rem;
  opacity: 0.8;
}

.footer-copy {
  font-size: 0.85rem;
  font-weight: 600;
}

.footer-link {
  color: #A7F3D0;
  font-size: 0.82rem;
  text-decoration: none;
  transition: color var(--transition-fast);
}
.footer-link:hover { color: #fff; text-decoration: underline; }

.footer-dev {
  font-size: 0.88rem;
  font-weight: 500;
  color: rgba(255,255,255,0.9);
  margin-top: 2px;
}
.footer-dev strong { color: #FFE07A; }

.footer-contacts {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  margin: 6px 0;
}

.footer-contact-item {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color var(--transition-fast);
}
.footer-contact-item:hover { color: #fff; }

/* Certification Section */
.footer-cert-section {
  width: 100%;
  max-width: 700px;
  margin: 12px auto 6px;
  padding: 14px 16px;
  background: rgba(255,255,255,0.08);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255,255,255,0.15);
}

.footer-cert-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #A7F3D0;
  margin-bottom: 10px;
  letter-spacing: 0.5px;
}

.footer-cert-cards {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.footer-cert-card {
  background: linear-gradient(135deg, rgba(255,255,255,0.15), rgba(255,255,255,0.05));
  border: 1px solid rgba(167,243,208,0.35);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  text-align: center;
  min-width: 160px;
  flex: 1;
  max-width: 210px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.1);
  position: relative;
  overflow: hidden;
}
.footer-cert-card::before {
  content: '';
  position: absolute;
  top: 0; left: -100%; width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
  transition: left 0.5s ease;
}
.footer-cert-card:hover::before {
  left: 100%;
}

.footer-cert-card:hover {
  background: linear-gradient(135deg, rgba(167,243,208,0.25), rgba(255,255,255,0.12));
  border-color: rgba(167,243,208,0.5);
  transform: translateY(-4px) scale(1.03);
  box-shadow: 0 8px 24px rgba(0,0,0,0.25), 0 0 15px rgba(167,243,208,0.2);
}

.cert-logo {
  height: 38px;
  object-fit: contain;
  margin-bottom: 8px;
  opacity: 1;
  filter: drop-shadow(0 0 6px rgba(255,255,255,0.5)) brightness(1.15);
  transition: all 0.3s ease;
}
.footer-cert-card:hover .cert-logo {
  filter: drop-shadow(0 0 12px rgba(255,255,255,0.8)) brightness(1.3);
  transform: scale(1.1);
}

.cert-label {
  display: block;
  font-size: 0.76rem;
  color: rgba(255,255,255,0.85);
  margin-bottom: 4px;
  font-weight: 500;
}

.cert-number {
  display: block;
  font-size: 0.88rem;
  color: #FFE07A;
  font-weight: 700;
  letter-spacing: 0.5px;
  direction: ltr;
  text-shadow: 0 0 8px rgba(255,224,122,0.4);
}


/* ═══════════════════════════════════════════
   RESPONSIVE — Mobile First
═══════════════════════════════════════════ */

/* ── Tablet (≤ 900px) ── */
@media (max-width: 900px) {
  .header-content { padding: 24px 16px; }
  .header-title { font-size: 1.5rem; }
  .header-subtitle { font-size: 0.88rem; }
  .header-msd-logo { height: 58px; }
  .main-container { padding: 16px 12px; }
  .salary-summary { grid-template-columns: repeat(2, 1fr); }
  .results-grid { grid-template-columns: repeat(2, 1fr); }
  .allowance-row { grid-template-columns: 1fr 1fr auto; gap: 10px; }
}

/* ── Mobile (≤ 640px) ── */
@media (max-width: 640px) {
  /* Header */
  .header-content { padding: 18px 12px; }
  .header-title { font-size: 1.2rem; letter-spacing: 0; }
  .header-subtitle { font-size: 0.82rem; }
  .header-msd-logo { height: 48px; max-width: 170px; }
  .header-logo-wrap { margin-bottom: 12px; }

  /* Nav tabs — icons only on very small */
  .nav-tabs-inner { padding: 0 6px; gap: 2px; }
  .nav-tab { padding: 10px 10px; font-size: 0.78rem; gap: 4px; }
  .nav-tab .tab-text { font-size: 0.75rem; }

  /* Cards */
  .card-header { padding: 14px 16px; gap: 10px; }
  .card-header-icon { width: 36px; height: 36px; font-size: 1rem; }
  .card-header h2 { font-size: 1rem; }
  .card-body { padding: 16px; }

  /* Form grid — 1 column */
  .form-grid { grid-template-columns: 1fr; gap: 14px; }

  /* Allowance row — stack vertically */
  .allowance-row {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
  }
  .btn-remove-allowance { width: 100%; height: 36px; }

  /* Salary summary — 2 columns */
  .salary-summary {
    grid-template-columns: repeat(2, 1fr);
    padding: 16px 12px;
    gap: 12px;
  }
  .salary-item .value { font-size: 1.1rem; }
  .salary-item-net { grid-column: 1 / -1; }

  /* Results */
  .results-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .result-card { padding: 14px 10px; }
  .result-card .result-value { font-size: 1.2rem; }

  /* Buttons */
  .btn-group { flex-direction: column; gap: 8px; }
  .btn-group .btn { width: 100%; justify-content: center; }
  .btn-lg { padding: 14px 20px; font-size: 0.95rem; }

  /* Modal — full screen */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 92vh;
  }
  .modal-header { padding: 16px 20px; }
  .modal-footer { flex-direction: column; padding: 16px; gap: 8px; }
  .modal-footer .btn { width: 100%; }

  /* Tables — scroll */
  .table-responsive { font-size: 0.8rem; }
  .data-table thead th,
  .data-table tbody td { padding: 8px 10px; }

  /* Calc method table */
  .calc-method-table { font-size: 0.78rem; }
  .calc-method-table td { padding: 7px 10px; }

  /* Main container */
  .main-container { padding: 12px 8px; }
  .card { margin-bottom: 14px; }

  /* Footer */
  .app-footer { padding: 18px 14px; gap: 4px; }
  .footer-msd-logo { height: 34px; }
}

/* ── Very small (≤ 380px) ── */
@media (max-width: 380px) {
  .nav-tab .tab-text { display: none; }
  .nav-tab .tab-icon { font-size: 1.25rem; }
  .nav-tab { padding: 10px 14px; }
  .header-title { font-size: 1.05rem; }
  .results-grid { grid-template-columns: 1fr; }
  .salary-summary { grid-template-columns: 1fr; }
  .salary-item-net { grid-column: auto; }
}

/* ── Print ── */
@media print {
  .nav-tabs, .app-footer, .btn-group, .modal-overlay { display: none !important; }
  .app-header { box-shadow: none; }
  .section { display: block !important; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}

