﻿/* ── Section Header ───────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.section-title {
  font-family: var(--font-heading);
  font-size: clamp(18px, 3vw, 24px);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.section-subtitle {
  font-size: 14px;
  color: var(--color-text-mid);
  margin-top: 2px;
}

/* ── Card ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--color-white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.card-title {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text);
}

.card-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-primary);
}

/* ── Badge ────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.badge--blue   { background: #EFF6FF; color: #1D4ED8; }
.badge--green  { background: #F0FDF4; color: #059669; }
.badge--red    { background: #FEF2F2; color: #DC2626; }
.badge--yellow { background: #FFFBEB; color: #B45309; }
.badge--gray   { background: var(--color-surface-mid); color: var(--color-text-mid); }

/* ── Button ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-link {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: inherit;
  font-weight: 600;
  color: var(--color-primary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s;
}
.btn-link:hover:not(:disabled) { color: var(--color-primary-dark); text-decoration: underline; }
.btn-link:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary { background: var(--color-primary); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--color-primary-dark); }

.btn--ghost {
  background: transparent;
  color: var(--color-text-mid);
  border: 1px solid var(--color-border);
}
.btn--ghost:hover:not(:disabled) { background: var(--color-surface-mid); }

.btn--danger { color: var(--color-error); border-color: #FECACA; }
.btn--danger:hover:not(:disabled) { background: #FEF2F2; }

.btn--sm { padding: 6px 14px; font-size: 13px; }
.btn--lg { padding: 13px 28px; font-size: 15px; }
.btn--full { width: 100%; justify-content: center; }

/* ── Alert ────────────────────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  margin-bottom: 1rem;
}

.alert-icon { flex-shrink: 0; margin-top: 1px; }

.alert--error   { background: #FEF2F2; border: 1px solid #FECACA; color: var(--color-error); }
.alert--warning { background: #FFFBEB; border: 1px solid #FDE68A; color: #92400E; }
.alert--success { background: #F0FDF4; border: 1px solid #A7F3D0; color: #065F46; }
.alert--info    { background: #EFF6FF; border: 1px solid #BFDBFE; color: #1E40AF; }

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: 240px;
  background: var(--color-navy);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 200;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-navy-mid);
}

.sidebar-logo-img {
  height: 36px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}

.sidebar-brand {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  letter-spacing: -0.01em;
  display: block;
}

.sidebar-tagline {
  font-size: 11px;
  color: var(--color-text-mid);
  display: block;
}

.sidebar-nav {
  padding: 12px 10px;
  flex: 1;
  overflow-y: auto;
}

.sidebar-group-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--color-text-mid);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 8px 10px;
}

/* ── Spinner ──────────────────────────────────────────────────────────────── */
.spinner-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  gap: 0.75rem;
}

.spinner-icon { font-size: 28px; color: var(--color-primary); }
.spinner-label { font-size: 14px; color: var(--color-text-mid); }

/* ── Stats Grid ───────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--color-white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

/* Linked stat card (renders as <a>) */
a.stat-card--link {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
a.stat-card--link:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.10);
  border-color: var(--color-primary);
}

.stat-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.stat-card-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-mid);
}

.stat-card-icon-wrap {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
}

.stat-card-icon-wrap--blue   { background: #EFF6FF; color: var(--color-primary); }
.stat-card-icon-wrap--green  { background: #F0FDF4; color: var(--color-success); }
.stat-card-icon-wrap--yellow { background: #FFFBEB; color: var(--color-warning); }
.stat-card-icon-wrap--purple { background: #F5F3FF; color: #7C3AED; }

.stat-card-value {
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--color-text);
}

.stat-card-sub {
  font-size: 12px;
  color: var(--color-text-light);
  margin-top: 2px;
}

.mini-chart { display: block; width: 100%; height: 36px; margin-top: 0.75rem; }

/* ── Dashboard Charts Row ─────────────────────────────────────────────────── */
.dashboard-charts {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.chart-card .full-chart-wrap { padding: 1rem 1.5rem 1.25rem; }
.full-chart { display: block; width: 100%; height: 120px; }

.info-card { padding: 1.5rem; }
.plan-details { display: flex; flex-direction: column; gap: 1rem; margin-top: 0.5rem; }

.plan-stat { display: flex; justify-content: space-between; align-items: center; font-size: 14px; color: var(--color-text-mid); }
.plan-stat-value { font-weight: 700; color: var(--color-text); }

.credits-bar-label { display: flex; justify-content: space-between; font-size: 13px; color: var(--color-text-mid); margin-bottom: 6px; }
.credits-bar { height: 8px; background: var(--color-surface-mid); border-radius: 99px; overflow: hidden; }
.credits-bar-fill { height: 100%; background: var(--color-primary); border-radius: 99px; transition: width 0.4s ease; }

/* ── Data Table ───────────────────────────────────────────────────────────── */
.table-card { overflow: hidden; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table thead tr { background: var(--color-surface); }

.data-table th {
  padding: 10px 24px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-mid);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.data-table td {
  padding: 14px 24px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--color-surface); }

.table-empty { text-align: center; color: var(--color-text-light); padding: 3rem !important; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

.form-input-wrapper {
  position: relative;
}

.form-input-wrapper--icon .form-input {
  padding-left: 2.5rem;
}

.form-input-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--color-text-light);
  pointer-events: none;
}

.form-input,
.form-textarea {
  width: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  line-height: 1.5;
  appearance: none;
  -webkit-appearance: none;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--color-text-light);
}

.form-input:focus,
.form-textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-input:disabled {
  background: var(--color-surface-mid);
  color: var(--color-text-mid);
  cursor: not-allowed;
  opacity: 1;
}

select.form-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394A3B8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 2.25rem;
  cursor: pointer;
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

.form-hint {
  font-size: 12px;
  color: var(--color-text-light);
  line-height: 1.4;
}

.form-hint--error { color: var(--color-error); }

/* ── Utility classes ──────────────────────────────────────────────────────── */
.text-mid     { color: var(--color-text-mid); }
.text-light   { color: var(--color-text-light); }
.text-success { color: var(--color-success); }
.text-error   { color: var(--color-error); }
.text-warning { color: var(--color-warning); }
.mono         { font-family: var(--font-mono); font-size: 13px; }
.mono--sm     { font-size: 12px; }
.rtl          { direction: rtl; text-align: right; }
