/* ========== Admin Theme ========== */
:root {
  --admin-bg: #0d0d1a;
  --admin-surface: #14142b;
  --admin-gold: #c9a84c;
  --admin-gold-light: #e4c76b;
  --admin-gold-rgb: 201, 168, 76;
  --admin-border: rgba(var(--admin-gold-rgb), 0.12);
  --admin-text: #e0e0e8;
  --admin-text-muted: #7a7a90;
  --admin-white: #ffffff;
  --admin-danger: #e74c3c;
  --admin-success: #4caf50;
  --admin-font: 'Inter', sans-serif;
}

[data-theme="light"] {
  --admin-bg: #f7f5f0;
  --admin-surface: #ffffff;
  --admin-gold: #9a7820;
  --admin-gold-light: #c9a84c;
  --admin-gold-rgb: 154, 120, 32;
  --admin-border: rgba(154, 120, 32, 0.22);
  --admin-text: #1e1e2e;
  --admin-text-muted: #4a4a60;
  --admin-white: #1a1a2a;
}

/* ========== Light Mode: Admin-Specific Overrides ========== */

/* Header */
[data-theme="light"] .admin-header {
  background: #ffffff;
  box-shadow: 0 1px 0 rgba(0,0,0,0.08);
}

/* Inputs & Selects */
[data-theme="light"] input[type="text"],
[data-theme="light"] input[type="password"],
[data-theme="light"] input[type="email"],
[data-theme="light"] input[type="number"],
[data-theme="light"] input[type="date"],
[data-theme="light"] textarea,
[data-theme="light"] select {
  background: #ffffff;
  border-color: rgba(154, 120, 32, 0.25);
  color: #1e1e2e;
}

[data-theme="light"] input::placeholder,
[data-theme="light"] textarea::placeholder {
  color: #8a8a9a;
}

/* Tables */
[data-theme="light"] .projects-table,
[data-theme="light"] .admin-table {
  color: #1e1e2e;
}

[data-theme="light"] .projects-table th,
[data-theme="light"] .admin-table th {
  color: #4a4a60;
  background: rgba(154, 120, 32, 0.05);
  border-bottom-color: rgba(154, 120, 32, 0.2);
}

[data-theme="light"] .projects-table td,
[data-theme="light"] .admin-table td {
  color: #1e1e2e;
  border-bottom-color: rgba(154, 120, 32, 0.08);
}

[data-theme="light"] .projects-table tr:hover td,
[data-theme="light"] .admin-table tr:hover td {
  background: rgba(154, 120, 32, 0.04);
}

/* Tabs */
[data-theme="light"] .admin-tabs {
  background: #ffffff;
  border-bottom-color: rgba(154, 120, 32, 0.2);
}

[data-theme="light"] .admin-tab {
  color: #4a4a60;
}

[data-theme="light"] .admin-tab:hover {
  color: #9a7820;
}

[data-theme="light"] .admin-tab.active {
  color: #9a7820;
  border-bottom-color: #9a7820;
}

/* KPI Cards */
[data-theme="light"] .finance-kpi-card {
  background: #ffffff;
  border-color: rgba(154, 120, 32, 0.18);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

[data-theme="light"] .finance-kpi-label {
  color: #4a4a60;
}

/* Badges */
[data-theme="light"] .badge-active { background: rgba(76,175,80,0.15); color: #2e7d32; }
[data-theme="light"] .badge-selling { background: rgba(255,152,0,0.15); color: #e65100; }
[data-theme="light"] .badge-upcoming { background: rgba(33,150,243,0.15); color: #1565c0; }
[data-theme="light"] .badge-sold { background: rgba(158,158,158,0.15); color: #424242; }
[data-theme="light"] .badge-suspended { background: rgba(244,67,54,0.15); color: #c62828; }

/* Sections */
[data-theme="light"] .admin-section {
  background: #ffffff;
  border-color: rgba(154, 120, 32, 0.18);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

/* Table wrapper */
[data-theme="light"] .table-wrapper {
  border-color: rgba(154, 120, 32, 0.15);
}

/* Buttons */
[data-theme="light"] .btn-outline {
  color: #4a4a60;
  border-color: rgba(154, 120, 32, 0.3);
}

[data-theme="light"] .btn-outline:hover {
  color: #9a7820;
  background: rgba(154, 120, 32, 0.06);
}

/* Finance table rows */
[data-theme="light"] .partner-row:hover td {
  background: rgba(154, 120, 32, 0.04) !important;
}

/* Profit details row */
[data-theme="light"] tr.partner-row { color: #1e1e2e; }

/* Header KPI */
[data-theme="light"] .header-kpi {
  background: rgba(154, 120, 32, 0.06);
  border-color: rgba(154, 120, 32, 0.2);
}

/* Profit KPI cards background */
[data-theme="light"] .finance-section {
  background: #ffffff;
}

/* Timeline bars */
[data-theme="light"] .timeline-container {
  background: #ffffff;
  border-color: rgba(154, 120, 32, 0.18);
}

[data-theme="light"] .timeline-tick {
  border-left-color: rgba(0,0,0,0.1);
}

[data-theme="light"] .timeline-tick-label {
  background: #ffffff;
  color: #4a4a60;
}

/* Visibility toggle */
[data-theme="light"] .toggle-slider {
  background: #e0dbd5;
}

[data-theme="light"] .toggle-slider::after {
  background: #8a8a9a;
}

/* Inline-styled dark rgba colors used in finance JS for rows */
[data-theme="light"] #working-capital-tbody tr {
  border-bottom-color: rgba(0,0,0,0.06) !important;
}

[data-theme="light"] #working-capital-tbody tr:hover {
  background: rgba(154, 120, 32, 0.04) !important;
}

/* Profit distribution table */
[data-theme="light"] #dist-tbody tr {
  border-bottom-color: rgba(0,0,0,0.06) !important;
}

/* (Handled above in comprehensive light mode block) */

.admin-theme-toggle {
  background: transparent;
  border: 1px solid var(--admin-border);
  color: var(--admin-text-muted);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  transition: 0.2s ease;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.admin-theme-toggle:hover {
  border-color: var(--admin-gold);
  color: var(--admin-gold);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--admin-font);
  background: var(--admin-bg);
  color: var(--admin-text);
  min-height: 100vh;
}

/* ========== Login ========== */
.login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 12px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-logo {
  font-size: 2rem;
  font-weight: 700;
  color: var(--admin-gold);
  letter-spacing: 4px;
  margin-bottom: 8px;
}

.login-card h2 {
  color: var(--admin-text-muted);
  font-size: 1rem;
  font-weight: 400;
  margin-bottom: 32px;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.error-msg {
  color: var(--admin-danger);
  font-size: 0.85rem;
  min-height: 20px;
}

/* ========== Buttons ========== */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s ease;
  font-family: var(--admin-font);
  text-decoration: none;
  text-align: center;
}

.btn-primary {
  background: var(--admin-gold);
  color: var(--admin-bg);
}

.btn-primary:hover {
  background: var(--admin-gold-light);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--admin-border);
  color: var(--admin-text-muted);
}

.btn-outline:hover {
  border-color: var(--admin-gold);
  color: var(--admin-gold);
}

.btn-danger {
  background: rgba(231, 76, 60, 0.15);
  color: var(--admin-danger);
}

.btn-danger:hover {
  background: rgba(231, 76, 60, 0.25);
}

.btn-edit {
  background: rgba(var(--admin-gold-rgb), 0.15);
  color: var(--admin-gold);
}

.btn-edit:hover {
  background: rgba(var(--admin-gold-rgb), 0.25);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

.btn-xs {
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 4px;
}

.btn-icon {
  background: rgba(231, 76, 60, 0.2);
  color: var(--admin-danger);
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ========== Form Controls ========== */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="file"],
textarea,
select {
  background: var(--admin-bg);
  border: 1px solid var(--admin-border);
  border-radius: 6px;
  padding: 12px 16px;
  font-size: 0.9rem;
  color: var(--admin-text);
  font-family: var(--admin-font);
  width: 100%;
  transition: 0.2s ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--admin-gold);
  box-shadow: 0 0 0 3px rgba(var(--admin-gold-rgb), 0.1);
}

textarea {
  resize: vertical;
}

select {
  cursor: pointer;
}

label {
  display: block;
  color: var(--admin-text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ========== Header ========== */
.admin-header {
  background: var(--admin-surface);
  border-bottom: 1px solid var(--admin-border);
  padding: 4px 16px;
  position: relative;
}

.admin-header-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-header h1 {
  font-size: 1.3rem;
  color: var(--admin-gold);
  letter-spacing: 2px;
}

.admin-header h1 span {
  color: var(--admin-text-muted);
  font-weight: 400;
}

.admin-header-actions {
  display: flex;
  gap: 8px;
}

.header-kpi {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  white-space: nowrap;
}

.header-kpi span {
  color: var(--admin-text-muted);
  font-size: 11px;
  line-height: 1.1;
}

.header-kpi strong {
  color: var(--admin-gold);
  font-size: 18px;
  line-height: 1.1;
}

/* ========== Main ========== */
.admin-main {
  padding: 32px 24px;
}

.admin-container {
  max-width: 1200px;
  margin: 0 auto;
}

.admin-section {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 12px;
  padding: 32px;
  margin-bottom: 24px;
}

.admin-section h2 {
  color: var(--admin-gold);
  font-size: 1.2rem;
  margin-bottom: 24px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.section-header h2 {
  margin-bottom: 0;
}

.project-form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.project-form-toggle-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--admin-border);
  background: rgba(var(--admin-gold-rgb), 0.12);
  color: var(--admin-gold);
  font-size: 1.4rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: 0.2s ease;
}

.project-form-toggle-btn:hover {
  border-color: var(--admin-gold);
  background: rgba(var(--admin-gold-rgb), 0.22);
}

.project-form-toggle-btn[aria-expanded="true"] {
  background: var(--admin-gold);
  color: var(--admin-bg);
}

/* ========== Form Layout ========== */
.form-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.form-row-4 {
  grid-template-columns: repeat(4, 1fr);
}

.form-group {
  display: flex;
  flex-direction: column;
}

/* ========== Image Preview ========== */
.image-preview {
  position: relative;
  display: inline-block;
  margin-bottom: 16px;
}

.image-preview img {
  max-width: 200px;
  max-height: 150px;
  border-radius: 8px;
  border: 1px solid var(--admin-border);
  object-fit: cover;
}

.image-preview .btn-icon {
  position: absolute;
  top: -8px;
  right: -8px;
}

/* ========== Images List ========== */
.images-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.image-preview-item {
  position: relative;
  display: inline-block;
}

.image-preview-item img {
  width: 120px;
  height: 90px;
  border-radius: 8px;
  border: 1px solid var(--admin-border);
  object-fit: cover;
}

.image-preview-item .btn-icon {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  font-size: 14px;
  background: #e74c3c;
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-number {
  position: absolute;
  bottom: 4px;
  left: 4px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
}

.images-counter {
  font-size: 0.85em;
  color: var(--admin-gold);
  font-weight: 600;
}

.hero-bg-preview {
  position: relative;
  display: inline-block;
  margin-top: 8px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--admin-border);
}

.hero-bg-preview img {
  max-width: 300px;
  max-height: 150px;
  object-fit: cover;
  display: block;
}

.hero-bg-preview .btn-icon {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(231, 76, 60, 0.9);
  color: #fff;
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ========== Theme Color Picker ========== */
.color-picker-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.color-input {
  width: 60px;
  height: 42px;
  border: 2px solid var(--admin-border);
  border-radius: 8px;
  cursor: pointer;
  padding: 2px;
  background: var(--admin-surface);
}

.color-input::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.color-input::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}

.hex-input {
  width: 100px;
  padding: 8px 12px;
  border: 1px solid var(--admin-border);
  border-radius: 6px;
  background: var(--admin-bg);
  color: var(--admin-text);
  font-family: monospace;
  font-size: 0.95rem;
  text-transform: uppercase;
}

.hex-input:focus {
  outline: none;
  border-color: var(--admin-gold);
}

.theme-preview {
  display: flex;
  gap: 12px;
  margin: 16px 0;
}

.theme-swatch {
  flex: 1;
  height: 60px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.theme-presets {
  margin: 16px 0;
}

.theme-presets label {
  display: block;
  margin-bottom: 8px;
  color: var(--admin-text-muted);
  font-size: 0.85rem;
}

.preset-colors {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.preset-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
}

.preset-btn:hover {
  transform: scale(1.15);
}

.preset-btn.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.3);
}

/* ========== Section Visibility ========== */
.section-desc {
  color: var(--admin-text-muted);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.visibility-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.visibility-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.visibility-toggle:hover {
  border-color: var(--admin-gold);
}

.visibility-toggle input {
  display: none;
}

.toggle-slider {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--admin-bg);
  border-radius: 12px;
  transition: background 0.3s;
  flex-shrink: 0;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: var(--admin-text-muted);
  border-radius: 50%;
  transition: transform 0.3s, background 0.3s;
}

.visibility-toggle input:checked + .toggle-slider {
  background: var(--admin-gold);
}

.visibility-toggle input:checked + .toggle-slider::after {
  transform: translateX(20px);
  background: #fff;
}

.toggle-label {
  font-size: 0.95rem;
  color: var(--admin-text);
  font-weight: 500;
}

/* ========== Table ========== */
.table-wrapper {
  overflow-x: auto;
}

.finance-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
}

.admin-lang-switcher {
  position: relative;
  display: inline-flex;
}

.admin-lang-trigger {
  border: 1px solid var(--admin-border);
  background: transparent;
  color: var(--admin-text);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.admin-lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 150px;
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  padding: 6px;
  display: none;
  z-index: 20;
}

.admin-lang-menu.open {
  display: block;
}

.admin-lang-btn {
  width: 100%;
  text-align: start;
  border: 1px solid transparent;
  background: transparent;
  color: var(--admin-text);
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 12px;
  margin-bottom: 4px;
}

.admin-lang-btn:last-child {
  margin-bottom: 0;
}

.admin-lang-btn.active {
  background: var(--admin-gold);
  color: #fff;
  border-color: var(--admin-gold);
}

.finance-toolbar select {
  min-width: 240px;
}

.finance-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.finance-kpi-card {
  border: 1px solid var(--admin-border);
  background: var(--admin-surface);
  border-radius: 8px;
  padding: 14px;
}

.finance-kpi-label {
  color: var(--admin-text-muted);
  font-size: 12px;
  display: block;
  margin-bottom: 6px;
}

.finance-grid-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.finance-grid-form-6 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.finance-grid-form input,
.finance-grid-form select {
  width: 100%;
}

.analytics-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.analytics-kpi-card {
  border: 1px solid var(--admin-border);
  border-radius: 10px;
  background: var(--admin-surface);
  padding: 14px;
}

.analytics-kpi-label {
  display: block;
  color: var(--admin-text-muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.analytics-bars {
  display: grid;
  gap: 10px;
}

.analytics-bar-row {
  display: grid;
  grid-template-columns: 150px 1fr 80px;
  align-items: center;
  gap: 10px;
}

.analytics-bar-label {
  color: var(--admin-text);
  font-size: 13px;
}

.analytics-bar-track {
  width: 100%;
  height: 14px;
  background: rgba(var(--admin-gold-rgb), 0.1);
  border-radius: 999px;
  overflow: hidden;
}

.analytics-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--admin-gold), var(--admin-gold-light));
  border-radius: 999px;
}

.analytics-bar-value {
  color: var(--admin-text-muted);
  font-size: 12px;
  text-align: end;
}

@media (max-width: 1024px) {
  .admin-header-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .finance-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .analytics-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .finance-grid-form,
  .finance-grid-form-6 {
    grid-template-columns: 1fr;
  }

  .analytics-bar-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}

.projects-table {
  width: 100%;
  border-collapse: collapse;
}

.projects-table th {
  text-align: start;
  padding: 12px 16px;
  color: var(--admin-text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--admin-border);
}

.projects-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--admin-border);
  font-size: 0.9rem;
  vertical-align: middle;
}

.projects-table tr:hover td {
  background: rgba(var(--admin-gold-rgb), 0.03);
}

.projects-table .thumb {
  width: 60px;
  height: 45px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid var(--admin-border);
}

.projects-table .no-thumb {
  width: 60px;
  height: 45px;
  border-radius: 4px;
  background: var(--admin-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--admin-text-muted);
  font-size: 0.7rem;
}

.table-actions {
  display: flex;
  gap: 8px;
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-badge.active {
  background: rgba(76, 175, 80, 0.15);
  color: var(--admin-success);
}

.status-badge.completed,
.status-badge.sold {
  background: rgba(var(--admin-gold-rgb), 0.15);
  color: var(--admin-gold);
}

.status-badge.upcoming {
  background: rgba(100, 149, 237, 0.15);
  color: #6495ed;
}

.status-badge.selling {
  background: rgba(255, 152, 0, 0.15);
  color: #ff9800;
}

.status-badge.suspended {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.empty-msg {
  text-align: center;
  color: var(--admin-text-muted);
  padding: 40px 0;
}

/* ========== Tabs ========== */
.admin-tabs {
  background: var(--admin-surface);
  border-bottom: 1px solid var(--admin-border);
  padding: 0 15px;
  overflow-x: auto;
  scrollbar-width: none;
}
.admin-tabs::-webkit-scrollbar {
  display: none;
}

.admin-tab {
  background: none;
  border: none;
  color: var(--admin-text-muted);
  font-family: var(--admin-font);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: 0.2s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.admin-tab:hover {
  color: var(--admin-text);
}

.admin-tab.active {
  color: var(--admin-gold);
  border-bottom-color: var(--admin-gold);
}

/* ========== Content Section Nav ========== */
.content-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.content-nav-btn {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  color: var(--admin-text-muted);
  font-family: var(--admin-font);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: 0.2s ease;
}

.content-nav-btn:hover {
  border-color: var(--admin-gold);
  color: var(--admin-text);
}

.content-nav-btn.active {
  background: var(--admin-gold);
  border-color: var(--admin-gold);
  color: var(--admin-bg);
}

/* ========== Content Item Cards ========== */
.content-item-card {
  background: var(--admin-bg);
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}

.content-item-card h4 {
  color: var(--admin-gold);
  font-size: 0.95rem;
  margin-bottom: 12px;
}

.content-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.content-item-header h4 {
  margin-bottom: 0;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
  .form-row,
  .form-row-4 {
    grid-template-columns: 1fr;
  }

  .admin-section {
    padding: 20px;
  }

  .admin-header-content {
    flex-direction: column;
    gap: 12px;
  }

  .projects-table th:nth-child(4),
  .projects-table td:nth-child(4) {
    display: none;
  }
}

/* Premium styled table for finance and profits details */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

.admin-table th {
  text-align: start;
  padding: 12px 16px;
  color: var(--admin-text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  border-bottom: 2px solid var(--admin-border);
  background: rgba(255,255,255,0.02);
}

.admin-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--admin-border);
  font-size: 0.9rem;
  color: #e0e0e0;
  vertical-align: middle;
}

.admin-table tr:hover td {
  background: rgba(255,255,255,0.03);
}

.admin-table input[type="number"] {
  border: 1px solid rgba(255,255,255,0.15) !important;
  background: rgba(0,0,0,0.3) !important;
  color: #fff !important;
  border-radius: 4px;
  padding: 4px 6px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.admin-table input[type="number"]:focus {
  border-color: var(--admin-gold) !important;
  outline: none;
  box-shadow: 0 0 0 2px rgba(var(--admin-gold-rgb), 0.2);
}

.table-container {
  overflow-x: auto;
  width: 100%;
}

/* ========== Projects Timeline (Gantt Chart) ========== */
.timeline-container {
  position: relative;
  width: 100%;
  overflow-x: auto;
  padding: 20px 0;
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  margin-top: 15px;
}

.timeline-grid {
  position: relative;
  min-width: 800px; /* Ensure scrolling if too narrow */
  padding: 20px 0;
}

/* The vertical tick marks for years/months */
.timeline-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px dashed rgba(255,255,255,0.1);
  pointer-events: none;
}
.timeline-tick-label {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--admin-text-muted);
  background: var(--admin-surface);
  padding: 0 4px;
}

/* Individual Project Rows */
.timeline-row {
  position: relative;
  height: 30px;
  margin-bottom: 8px;
}

/* The actual bar representing the project duration */
.timeline-bar {
  position: absolute;
  height: 24px;
  top: 3px;
  border-radius: 4px;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.timeline-bar:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.4);
}

/* Status Colors */
.timeline-bar.status-active { background: linear-gradient(90deg, #4caf50, #81c784); }
.timeline-bar.status-planning { background: linear-gradient(90deg, #2196f3, #64b5f6); }
.timeline-bar.status-suspended { background: linear-gradient(90deg, #f44336, #e57373); }
.timeline-bar.status-sold { background: linear-gradient(90deg, #9e9e9e, #bdbdbd); }
.timeline-bar.status-upcoming { background: linear-gradient(90deg, #ff9800, #ffb74d); }

/* ========== CEO Dashboard ========== */
.ceo-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.ceo-kpi-card {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 10px;
  padding: 20px;
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.ceo-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

.ceo-kpi-icon {
  font-size: 1.8rem;
  margin-bottom: 6px;
}

.ceo-kpi-value {
  font-size: 1.6rem;
  font-weight: 700;
  display: block;
  margin-bottom: 4px;
}

.ceo-kpi-label {
  font-size: 0.78rem;
  color: var(--admin-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ceo-health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.ceo-health-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border-radius: 10px;
  border: 1px solid var(--admin-border);
  background: var(--admin-surface);
}

.ceo-health-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.ceo-health-info {
  flex: 1;
}

.ceo-health-title {
  font-size: 0.85rem;
  font-weight: 600;
  display: block;
  margin-bottom: 2px;
}

.ceo-health-status {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 12px;
  display: inline-block;
}

.ceo-health-status.healthy { background: rgba(76,175,80,0.15); color: #4caf50; }
.ceo-health-status.warning { background: rgba(255,152,0,0.15); color: #ff9800; }
.ceo-health-status.danger { background: rgba(244,67,54,0.15); color: #f44336; }

.ceo-health-detail {
  display: block;
  font-size: 0.75rem;
  color: var(--admin-text-muted);
  margin-top: 4px;
}

/* Light mode CEO overrides */
[data-theme="light"] .ceo-kpi-card,
[data-theme="light"] .ceo-health-card {
  background: #ffffff;
  border-color: rgba(154, 120, 32, 0.18);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

/* ========================================== */
/* MODALS */
/* ========================================== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
}

.modal-content {
  background-color: var(--admin-surface);
  color: var(--admin-text);
  padding: 30px;
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  position: relative;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  border: 1px solid var(--admin-border);
  max-height: 90vh;
  overflow-y: auto;
}

.close-modal {
  position: absolute;
  top: 15px;
  left: 20px;
  font-size: 24px;
  cursor: pointer;
  color: var(--admin-text);
  opacity: 0.7;
  transition: opacity 0.2s;
}

.close-modal:hover {
  opacity: 1;
}

[data-theme="dark"] .close-modal {
  color: var(--text-color, #f0f0f0);
}

/* ==========================================================================
   Global loading indicator
   Driven by the fetch wrapper in admin-core.js — no per-call wiring needed.
   The dashboard fans out one request per project and re-aggregates every
   transaction in JS, so a first paint can take several seconds; without this
   the panel looks frozen or, worse, looks like it is showing real zeros.
   ========================================================================== */

/* Thin determinate-looking bar pinned to the top of the viewport. */
.app-loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 99999;
  background: transparent;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.app-loading-bar.is-active {
  opacity: 1;
}

.app-loading-bar > span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #00bcd4, #38bdf8, #c9a84c);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.7);
  border-radius: 0 3px 3px 0;
  /* Width is driven from JS: it creeps toward 90% while requests are in
     flight, then snaps to 100% on completion. */
  transition: width 0.3s ease;
}

/* Floating "loading" pill, bottom-start corner. Uses logical properties so it
   sits correctly in both the RTL (Arabic) and LTR (English) admin layouts. */
.app-loading-badge {
  position: fixed;
  bottom: 18px;
  inset-inline-start: 18px;
  z-index: 99999;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 15px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.93);
  border: 1px solid rgba(148, 163, 184, 0.25);
  color: #e2e8f0;
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

.app-loading-badge.is-active {
  opacity: 1;
  transform: translateY(0);
}

.app-loading-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(148, 163, 184, 0.35);
  border-top-color: #38bdf8;
  border-radius: 50%;
  animation: app-loading-spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes app-loading-spin {
  to { transform: rotate(360deg); }
}

/* Placeholder shimmer for KPI values that have not arrived yet. Applied by
   admin-core.js via markLoading()/clearLoading(). */
.is-loading-value {
  display: inline-block;
  min-width: 5.5em;
  color: transparent !important;
  border-radius: 4px;
  background: linear-gradient(90deg,
      rgba(148, 163, 184, 0.14) 25%,
      rgba(148, 163, 184, 0.28) 37%,
      rgba(148, 163, 184, 0.14) 63%);
  background-size: 400% 100%;
  animation: app-loading-shimmer 1.3s ease infinite;
}

@keyframes app-loading-shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* Respect users who have asked for reduced motion. */
@media (prefers-reduced-motion: reduce) {
  .app-loading-spinner { animation-duration: 2s; }
  .is-loading-value { animation: none; }
  .app-loading-bar > span { transition: none; }
}
