/* RootsToWorld Portal & Operations Management System CSS */
:root {
  --primary: #14431B;
  --primary-light: #1E6B2C;
  --primary-dark: #0A2910;
  --navy: #0A2540;
  --navy-light: #1E3A8A;
  --accent-gold: #D97706;
  --accent-gold-light: #FEF3C7;
  --bg-slate: #F8FAF8;
  --surface: #FFFFFF;
  --border: #E2E8F0;
  --border-focus: #14431B;
  --text-main: #0F172A;
  --text-muted: #64748B;
  --success: #16A34A;
  --warning: #D97706;
  --danger: #DC2626;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 28px rgba(0,0,0,0.12);
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-serif: 'Times New Roman', 'Baskerville', 'Georgia', serif;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-slate);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* Sidebar */
.sidebar {
  width: 280px;
  background-color: var(--navy);
  color: #F8FAFC;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  overflow-y: auto;
  border-right: 1px solid rgba(255,255,255,0.08);
}

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

.sidebar-logo-img {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: white;
  padding: 2px;
}

.sidebar-brand-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
}

.sidebar-brand-title .brand-green {
  color: #4ADE80;
}

.sidebar-brand-sub {
  font-size: 0.65rem;
  letter-spacing: 1.5px;
  color: #94A3B8;
  text-transform: uppercase;
  font-weight: 600;
}

.role-switcher-box {
  padding: 16px 20px;
  background: rgba(0,0,0,0.25);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.role-switcher-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #94A3B8;
  margin-bottom: 8px;
  display: block;
}

.role-select {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.1);
  color: white;
  border: 1px solid rgba(255,255,255,0.2);
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
}

.role-select option {
  background: var(--navy);
  color: white;
}

.sidebar-nav {
  padding: 20px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-category {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #64748B;
  padding: 12px 12px 6px;
  font-weight: 700;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: #CBD5E1;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.15s ease;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: white;
}

.nav-item.active {
  background: var(--primary);
  color: white;
  font-weight: 600;
}

.nav-icon {
  font-size: 1.1rem;
  width: 22px;
  display: inline-block;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 0.75rem;
  color: #94A3B8;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-footer a {
  color: #4ADE80;
  text-decoration: none;
}

/* Main Content Area */
.main-wrapper {
  margin-left: 280px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Top Header */
.top-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 90;
}

.page-title-area h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--navy);
}

.page-title-area p {
  font-size: 0.82rem;
  color: var(--text-muted);
}

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

.badge-role {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: #DCFCE7;
  color: #166534;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid #BBF7D0;
}

.btn-public-site {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--navy);
  color: white;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  transition: opacity 0.2s;
}

.btn-public-site:hover {
  opacity: 0.9;
}

/* Content Container */
.content-body {
  padding: 32px;
  max-width: 1400px;
  width: 100%;
}

/* Tab Panels */
.tab-panel {
  display: none;
}

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

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

.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--primary);
}

.metric-card.gold::before { background: var(--accent-gold); }
.metric-card.navy::before { background: var(--navy); }
.metric-card.blue::before { background: #2563EB; }

.metric-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 8px;
}

.metric-value {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.1;
  margin-bottom: 6px;
}

.metric-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Section Cards */
.portal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 32px;
  overflow: hidden;
}

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

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--navy);
}

.card-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.card-body {
  padding: 24px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  text-decoration: none;
}

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

.btn-primary:hover {
  background: var(--primary-light);
}

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

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

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

.btn-outline:hover {
  background: #F1F5F9;
  border-color: #CBD5E1;
}

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

.btn-gold {
  background: var(--accent-gold);
  color: white;
}

.btn-gold:hover {
  background: #B45309;
}

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

.portal-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.86rem;
}

.portal-table th {
  background: #F8FAFC;
  padding: 12px 16px;
  font-weight: 700;
  color: #475569;
  border-bottom: 2px solid var(--border);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.6px;
}

.portal-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  vertical-align: middle;
}

.portal-table tr:hover td {
  background: #F8FAF8;
}

/* Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-vetted { background: #DCFCE7; color: #15803D; border: 1px solid #BBF7D0; }
.status-pending { background: #FEF3C7; color: #B45309; border: 1px solid #FDE68A; }
.status-paid { background: #E0E7FF; color: #3730A3; border: 1px solid #C7D2FE; }
.status-progress { background: #DBEAFE; color: #1D4ED8; border: 1px solid #BFDBFE; }
.status-completed { background: #DCFCE7; color: #15803D; border: 1px solid #BBF7D0; }

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

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

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--navy);
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--text-main);
  background: white;
  transition: border-color 0.2s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(20, 67, 27, 0.1);
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
}

/* Revenue Split Box */
.revenue-split-box {
  background: #F0FDF4;
  border: 1px solid #BBF7D0;
  border-radius: var(--radius-md);
  padding: 20px;
  margin-top: 16px;
}

.split-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #166534;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.split-columns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.split-item {
  background: white;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid #E2E8F0;
  text-align: center;
}

.split-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.split-val {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--navy);
  margin-top: 4px;
}

.split-pct {
  font-size: 0.7rem;
  color: #15803D;
  font-weight: 700;
}

/* Official Documents View (Letter, Receipt, Certificate) */
.document-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 37, 64, 0.75);
  backdrop-filter: blur(4px);
  z-index: 2000;
  overflow-y: auto;
  padding: 40px 20px;
}

.document-modal.open {
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.document-wrapper {
  background: white;
  width: 100%;
  max-width: 850px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  position: relative;
  margin: auto;
  overflow: hidden;
}

.doc-toolbar {
  background: #F1F5F9;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Formal Letterhead Styling */
.official-letterhead {
  padding: 50px 60px;
  background: white;
  color: #1E293B;
  font-family: 'Times New Roman', 'Baskerville', 'Georgia', serif;
  line-height: 1.6;
}

.letter-header {
  border-bottom: 2px solid var(--primary);
  padding-bottom: 20px;
  margin-bottom: 30px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.letter-brand-logo {
  display: flex;
  align-items: center;
  gap: 14px;
}

.letter-brand-logo img {
  width: 60px;
  height: 60px;
}

.letter-company-meta {
  text-align: right;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: #475569;
  line-height: 1.4;
}

.letter-ref-bar {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 30px;
  padding: 8px 12px;
  background: #F8FAF8;
  border: 1px solid #E2E8F0;
  border-radius: 4px;
}

.letter-ref-no {
  color: var(--primary);
}

.letter-recipient-meta {
  margin-bottom: 24px;
  font-size: 1rem;
}

.letter-subject {
  font-size: 1.1rem;
  font-weight: bold;
  text-decoration: underline;
  margin-bottom: 20px;
  color: var(--navy);
}

.letter-body-content {
  font-size: 1.05rem;
  text-align: justify;
  margin-bottom: 40px;
  white-space: pre-line;
}

.letter-sign-section {
  margin-top: 40px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.official-stamp-box {
  width: 140px;
  height: 140px;
  border: 2px dashed #15803D;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  color: #15803D;
  font-family: var(--font-sans);
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  transform: rotate(-8deg);
  background: rgba(22, 163, 74, 0.04);
}

/* Formal Receipt Styling */
.official-receipt {
  padding: 50px 60px;
  background: white;
  font-family: var(--font-sans);
}

.receipt-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--navy);
  padding-bottom: 20px;
  margin-bottom: 24px;
}

.receipt-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--navy);
}

.receipt-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
  font-size: 0.88rem;
}

.receipt-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}

.receipt-table th, .receipt-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.receipt-table th {
  background: #F1F5F9;
  text-align: left;
  font-size: 0.8rem;
  text-transform: uppercase;
}

.receipt-total-row td {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--navy);
  border-top: 2px solid var(--navy);
}

/* Formal Certificate Styling */
.official-certificate {
  padding: 60px;
  background: #FCFDFD;
  border: 12px solid #14431B;
  outline: 3px solid #D97706;
  outline-offset: -8px;
  text-align: center;
  position: relative;
  font-family: 'Times New Roman', 'Baskerville', 'Georgia', serif;
}

.cert-emblem {
  width: 80px;
  height: 80px;
  margin: 0 auto 16px;
}

.cert-header-title {
  font-size: 1.1rem;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: #64748B;
  font-family: var(--font-sans);
  margin-bottom: 8px;
}

.cert-main-title {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--navy);
  margin-bottom: 20px;
}

.cert-subtext {
  font-size: 1.1rem;
  font-style: italic;
  color: #475569;
  margin-bottom: 12px;
}

.cert-recipient {
  font-size: 2.3rem;
  font-weight: bold;
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 6px;
  margin-bottom: 16px;
}

.cert-reason {
  font-size: 1.15rem;
  max-width: 650px;
  margin: 0 auto 30px;
  color: #1E293B;
  line-height: 1.5;
}

.cert-signatures {
  display: flex;
  justify-content: space-around;
  margin-top: 40px;
  padding-top: 20px;
}

.cert-sign-box {
  width: 200px;
  border-top: 1px solid #475569;
  padding-top: 6px;
  font-size: 0.82rem;
  font-family: var(--font-sans);
  color: #334155;
}

.cert-gold-seal {
  position: absolute;
  bottom: 40px;
  right: 50px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle, #FDE68A 0%, #D97706 80%);
  border: 3px solid #B45309;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-family: var(--font-sans);
  font-weight: 900;
  font-size: 0.65rem;
  text-transform: uppercase;
  box-shadow: 0 4px 10px rgba(217, 119, 6, 0.4);
}

/* Print Styles */
@media print {
  body {
    background: white !important;
  }
  .sidebar, .top-header, .doc-toolbar, .btn, .no-print {
    display: none !important;
  }
  .main-wrapper {
    margin-left: 0 !important;
  }
  .document-modal {
    position: static !important;
    background: white !important;
    padding: 0 !important;
    display: block !important;
  }
  .document-wrapper {
    box-shadow: none !important;
    border: none !important;
    max-width: 100% !important;
  }
}

/* Responsive */
@media (max-width: 1024px) {
  .sidebar {
    width: 240px;
  }
  .main-wrapper {
    margin-left: 240px;
  }
}

@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
  }
  .main-wrapper {
    margin-left: 0;
  }
  .split-columns {
    grid-template-columns: 1fr;
  }
}
