/* css/style.css */
/* CFO Intelligence — Professional Executive Design */
/* Navy / Green Visual Identity */

/* ============================================
   CSS VARIABLES & DESIGN TOKENS
   ============================================ */
:root {
  --color-navy: #0a192f;
  --color-navy-light: #112240;
  --color-navy-lighter: #1a365d;
  --color-green: #2d6a4f;
  --color-green-light: #40916c;
  --color-green-pale: #d8f3dc;
  --color-gold: #c9a227;
  --color-red: #c53030;
  --color-orange: #dd6b20;

  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #1e293b;
  --color-text-secondary: #64748b;
  --color-text-muted: #94a3b8;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --transition: all 0.2s ease;

  --font-ar: "Cairo", sans-serif;
  --font-en: "Inter", sans-serif;
  --font-mono: "SF Mono", "Fira Code", monospace;
}

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-en);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

html[lang="ar"] body {
  font-family: var(--font-ar);
}

a {
  color: var(--color-navy-lighter);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--color-green);
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
h1, h2, h3, h4 {
  font-weight: 700;
  line-height: 1.3;
  color: var(--color-navy);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

p {
  margin-bottom: 1rem;
  color: var(--color-text-secondary);
}

/* ============================================
   LAYOUT
   ============================================ */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

main {
  flex: 1;
  padding: 2rem 0;
}

/* ============================================
   HEADER & NAVIGATION
   ============================================ */
#main-header {
  background: var(--color-navy);
  color: white;
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

#main-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-logo {
  background: var(--color-green);
  color: white;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-weight: 800;
  font-size: 0.875rem;
  letter-spacing: -0.5px;
}

.nav-title {
  font-weight: 700;
  font-size: 1.125rem;
  color: white;
}

.nav-links {
  display: flex;
  gap: 0.5rem;
}

.nav-link {
  color: rgba(255, 255, 255, 0.8);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 500;
  transition: var(--transition);
}

.nav-link:hover,
.nav-link.active {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

.lang-toggle {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 0.4rem 0.875rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.lang-toggle:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.5);
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  font-family: inherit;
}

.btn-primary {
  background: var(--color-green);
  color: white;
}

.btn-primary:hover {
  background: var(--color-green-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--color-navy-lighter);
  color: white;
}

.btn-secondary:hover {
  background: var(--color-navy);
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--color-border);
  color: var(--color-text);
}

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

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

.btn-danger:hover {
  background: #9b2c2c;
}

.btn-group {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 1.5rem 0;
}

.btn-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--color-bg);
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
}

.btn-icon:hover {
  background: var(--color-border);
  color: var(--color-red);
}

/* ============================================
   CARDS
   ============================================ */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  padding: 1.5rem;
  transition: var(--transition);
}

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

/* ============================================
   FORMS & INPUTS
   ============================================ */
.input-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.input-group label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-secondary);
}

.input-group input,
.input-group select,
.input-group textarea {
  padding: 0.625rem 0.875rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
  transition: var(--transition);
}

.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
  outline: none;
  border-color: var(--color-green);
  box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.1);
}

.input-section {
  margin-bottom: 2rem;
}

.section-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-navy);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--color-green-pale);
}

/* ============================================
   TABS
   ============================================ */
.tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--color-bg);
  padding: 0.375rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  width: fit-content;
}

.tab-btn {
  padding: 0.5rem 1.25rem;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  font-weight: 600;
  font-size: 0.9375rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.tab-btn.active {
  background: var(--color-surface);
  color: var(--color-navy);
  box-shadow: var(--shadow-sm);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ============================================
   TRIAL BALANCE
   ============================================ */
.tb-row {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr 1fr auto;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.tb-row input {
  padding: 0.5rem 0.75rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-family: inherit;
}

.tb-row input:focus {
  outline: none;
  border-color: var(--color-green);
}

/* ============================================
   KPI CARDS
   ============================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.kpi-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.kpi-card.healthy::before { background: var(--color-green); }
.kpi-card.attention::before { background: var(--color-orange); }
.kpi-card.critical::before { background: var(--color-red); }

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.healthy { background: var(--color-green); }
.status-dot.attention { background: var(--color-orange); }
.status-dot.critical { background: var(--color-red); }

.status-text {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--color-navy);
  line-height: 1.2;
  margin-bottom: 0.25rem;
  font-family: var(--font-mono);
}

.kpi-label {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  font-weight: 500;
}

/* ============================================
   RATIOS SECTION
   ============================================ */
.ratios-section {
  margin-bottom: 2rem;
}

.section-heading {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-navy);
  margin-bottom: 1rem;
}

.ratios-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.ratio-item {
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  padding: 1rem;
  border: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.ratio-item.healthy { border-left: 4px solid var(--color-green); }
.ratio-item.attention { border-left: 4px solid var(--color-orange); }
.ratio-item.critical { border-left: 4px solid var(--color-red); }

html[dir="rtl"] .ratio-item.healthy { border-left: none; border-right: 4px solid var(--color-green); }
html[dir="rtl"] .ratio-item.attention { border-left: none; border-right: 4px solid var(--color-orange); }
html[dir="rtl"] .ratio-item.critical { border-left: none; border-right: 4px solid var(--color-red); }

.ratio-label {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  font-weight: 600;
}

.ratio-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-navy);
  font-family: var(--font-mono);
}

/* ============================================
   FINANCIAL STATEMENTS SUMMARY
   ============================================ */
.fs-section {
  margin-bottom: 2rem;
}

.fs-summary {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  border: 1px solid var(--color-border);
}

.fs-line {
  display: flex;
  justify-content: space-between;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9375rem;
}

.fs-line:last-child {
  border-bottom: none;
}

.fs-total {
  font-weight: 700;
  color: var(--color-navy);
}

/* ============================================
   INSIGHTS
   ============================================ */
.insights-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.insight-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

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

.insight-card.critical {
  border-left: 4px solid var(--color-red);
  background: #fff5f5;
}

.insight-card.attention {
  border-left: 4px solid var(--color-orange);
  background: #fffaf0;
}

.insight-card.healthy {
  border-left: 4px solid var(--color-green);
  background: #f0fff4;
}

html[dir="rtl"] .insight-card.critical { border-left: none; border-right: 4px solid var(--color-red); }
html[dir="rtl"] .insight-card.attention { border-left: none; border-right: 4px solid var(--color-orange); }
html[dir="rtl"] .insight-card.healthy { border-left: none; border-right: 4px solid var(--color-green); }

.insight-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.insight-severity {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-sm);
}

.insight-severity.critical {
  background: #fed7d7;
  color: #742a2a;
}

.insight-severity.attention {
  background: #feebc8;
  color: #7c2d12;
}

.insight-severity.healthy {
  background: #c6f6d5;
  color: #22543d;
}

.insight-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-navy);
  margin: 0;
}

.insight-explanation {
  color: var(--color-text);
  margin-bottom: 1rem;
  line-height: 1.6;
}

.insight-action {
  background: rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-sm);
  padding: 1rem;
  border: 1px solid var(--color-border);
}

.insight-action strong {
  color: var(--color-navy);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.insight-action p {
  margin: 0.5rem 0 0;
  color: var(--color-text-secondary);
}

.no-insights {
  text-align: center;
  padding: 3rem;
  color: var(--color-text-muted);
  font-size: 1.125rem;
}

/* ============================================
   INTEGRITY BANNER
   ============================================ */
.integrity-banner {
  background: #fff5f5;
  border: 1px solid #feb2b2;
  border-radius: var(--radius-md);
  padding: 1rem 1.5rem;
  margin-bottom: 1.5rem;
  color: #742a2a;
}

.integrity-banner strong {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 1rem;
}

.integrity-banner p {
  margin: 0;
  font-size: 0.9375rem;
}

.integrity-banner.hidden {
  display: none;
}

/* ============================================
   HERO / WELCOME
   ============================================ */
.hero {
  text-align: center;
  padding: 4rem 1rem;
  background: linear-gradient(135deg, var(--color-navy) 0%, var(--color-navy-light) 100%);
  color: white;
  border-radius: var(--radius-lg);
  margin-bottom: 2rem;
}

.hero h1 {
  font-size: 2.5rem;
  color: white;
  margin-bottom: 1rem;
}

.hero p {
  font-size: 1.125rem;
  color: rgba(255, 255, 255, 0.85);
  max-width: 600px;
  margin: 0 auto 2rem;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.feature-card {
  display: block;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  text-align: center;
  border: 1px solid var(--color-border);
  transition: var(--transition);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.feature-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--color-green);
}

.feature-icon {
  width: 48px;
  height: 48px;
  background: var(--color-green-pale);
  color: var(--color-green);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  font-size: 1.5rem;
}

.feature-card h3 {
  font-size: 1.125rem;
  margin-bottom: 0.5rem;
  color: var(--color-navy);
}

.feature-card p {
  font-size: 0.875rem;
  margin: 0;
}

/* ============================================
   FOOTER
   ============================================ */
footer {
  background: var(--color-navy);
  color: rgba(255, 255, 255, 0.6);
  text-align: center;
  padding: 1.5rem;
  font-size: 0.875rem;
  margin-top: auto;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .nav-links {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--color-navy);
    flex-direction: column;
    padding: 1rem;
    gap: 0.25rem;
  }

  .nav-links.open {
    display: flex;
  }

  .mobile-menu-btn {
    display: block;
  }

  .lang-toggle {
    display: none;
  }

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

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

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

  .tb-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
  }

  .hero h1 {
    font-size: 1.75rem;
  }

  .hero p {
    font-size: 1rem;
  }

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

  .btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .ratios-grid {
    grid-template-columns: 1fr;
  }

  .container {
    padding: 0 1rem;
  }

  main {
    padding: 1rem 0;
  }
}

/* ============================================
   PRINT
   ============================================ */
@media print {
  #main-header,
  .btn-group,
  .lang-toggle,
  .mobile-menu-btn {
    display: none !important;
  }

  .kpi-card,
  .ratio-item,
  .insight-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
  }
}

/* ============================================
   UTILITIES
   ============================================ */
.text-center { text-align: center; }
.mt-2 { margin-top: 1rem; }
.mb-2 { margin-bottom: 1rem; }
.hidden { display: none; }
