/* ========================================================
   DueKeep App Styles — extends theme.css design tokens
   ======================================================== */

/* ---- Nav ---- */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-user {
  font-size: 0.9rem;
  color: var(--fg-muted);
}

/* ---- Layout ---- */
.app-main {
  min-height: calc(100vh - 60px);
  background: var(--bg);
}

.page-wrap {
  max-width: 1160px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

.page-wrap.narrow {
  max-width: 720px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 40px;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 4px;
}

.page-sub {
  font-size: 0.9rem;
  color: var(--fg-muted);
}

.breadcrumb {
  display: block;
  font-size: 0.85rem;
  color: var(--fg-muted);
  text-decoration: none;
  margin-bottom: 8px;
}

.breadcrumb:hover { color: var(--fg); }

/* ---- Buttons ---- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--accent);
  color: #0a0f1a;
  font-weight: 600;
  font-size: 0.9rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s;
  white-space: nowrap;
}

.btn-primary:hover { opacity: 0.88; }
.btn-primary.btn-full { width: 100%; justify-content: center; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  padding: 10px 16px;
  background: transparent;
  color: var(--fg-muted);
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.btn-ghost:hover { color: var(--fg); border-color: rgba(139,151,176,0.4); }
.btn-ghost.btn-sm { padding: 6px 12px; font-size: 0.82rem; }

.btn-danger {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  background: transparent;
  color: #e05555;
  font-size: 0.82rem;
  border: 1px solid rgba(224, 85, 85, 0.3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
}

.btn-danger:hover { background: rgba(224, 85, 85, 0.08); }
.btn-danger.btn-sm { padding: 6px 12px; font-size: 0.82rem; }

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
}

.badge-outstanding {
  background: rgba(34, 214, 138, 0.1);
  color: var(--accent);
  border: 1px solid rgba(34, 214, 138, 0.2);
}

.badge-overdue {
  background: rgba(251, 146, 60, 0.12);
  color: #fb923c;
  border: 1px solid rgba(251, 146, 60, 0.25);
}

.badge-paid {
  background: rgba(139, 151, 176, 0.1);
  color: var(--fg-muted);
  border: 1px solid var(--border);
}

/* ---- Stats ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 40px;
}

.stat-card {
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.stat-value.accent { color: var(--accent); }
.stat-value.muted { color: var(--fg-muted); }

.stat-label {
  font-size: 0.82rem;
  color: var(--fg-muted);
}

/* ---- Invoice table ---- */
.invoice-table {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.table-header {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.table-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--fg);
  align-items: center;
  transition: background 0.15s;
}

.table-row:last-child { border-bottom: none; }
.table-row:hover { background: rgba(255,255,255,0.02); }

.client-name {
  font-weight: 500;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.client-email {
  font-size: 0.8rem;
  color: var(--fg-muted);
  font-weight: 400;
}

.amount { font-family: 'Space Grotesk', sans-serif; font-weight: 600; }
.due-date { font-size: 0.88rem; color: var(--fg-muted); }

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 80px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.empty-icon { font-size: 2.5rem; margin-bottom: 16px; }
.empty-state h3 { font-size: 1.25rem; margin-bottom: 8px; }
.empty-state p { color: var(--fg-muted); margin-bottom: 24px; font-size: 0.95rem; }

.empty-inline {
  padding: 24px;
  color: var(--fg-muted);
  font-size: 0.9rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ---- Forms ---- */
.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 24px;
}

.invoice-form { display: flex; flex-direction: column; gap: 20px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.field { display: flex; flex-direction: column; gap: 8px; }

.field label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--fg-muted);
}

.field-optional { font-weight: 400; opacity: 0.6; }

.field input,
.field textarea,
.field select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--fg);
  padding: 10px 14px;
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.15s;
  width: 100%;
}

.field input::placeholder,
.field textarea::placeholder { color: var(--fg-muted); opacity: 0.6; }

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: rgba(34, 214, 138, 0.4);
  box-shadow: 0 0 0 3px rgba(34, 214, 138, 0.08);
}

.field textarea { resize: vertical; min-height: 80px; }

/* Chrome date input styling */
.field input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.6);
  cursor: pointer;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 8px;
}

.form-hint {
  display: flex;
  gap: 16px;
  padding: 20px 24px;
  background: var(--accent-dim);
  border: 1px solid rgba(34, 214, 138, 0.2);
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--fg-muted);
  line-height: 1.6;
}

.hint-icon { font-size: 1.25rem; flex-shrink: 0; }

/* ---- Invoice detail ---- */
.detail-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  margin-bottom: 48px;
}

.detail-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}

.detail-amount {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 24px;
}

.detail-meta { display: flex; flex-direction: column; gap: 12px; }

.meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.meta-row:last-child { border-bottom: none; padding-bottom: 0; }
.meta-row span { color: var(--fg-muted); }
.meta-row strong { font-weight: 500; }

.actions-card { display: flex; flex-direction: column; gap: 16px; }
.actions-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 4px; }

.actions-label { font-size: 0.8rem; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.06em; }

.status-options { display: flex; flex-wrap: wrap; gap: 8px; }

.danger-zone {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.header-actions { display: flex; align-items: center; gap: 12px; padding-top: 8px; }

/* ---- Sections ---- */
.section { margin-top: 48px; }

.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--fg);
}

/* ---- Reminder list ---- */
.reminder-list { display: flex; flex-direction: column; gap: 16px; }

.reminder-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}

.reminder-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.reminder-tone {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 3px 10px;
  border-radius: 100px;
  text-transform: capitalize;
}

.reminder-date { font-size: 0.82rem; color: var(--fg-muted); }

.reminder-subject { font-weight: 500; font-size: 0.95rem; margin-bottom: 10px; }

.reminder-body {
  font-size: 0.88rem;
  color: var(--fg-muted);
  line-height: 1.7;
  white-space: pre-wrap;
}

/* ---- Auth pages ---- */
.auth-page {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-wrap {
  width: 100%;
  max-width: 420px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
}

.auth-brand {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
}

.auth-card {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
}

.auth-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.auth-sub { font-size: 0.9rem; color: var(--fg-muted); margin-bottom: 28px; }

.auth-form { display: flex; flex-direction: column; gap: 16px; }

.auth-switch {
  text-align: center;
  margin-top: 20px;
  font-size: 0.88rem;
  color: var(--fg-muted);
}

.auth-switch a { color: var(--accent); text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

/* ---- Alerts ---- */
.alert-error {
  padding: 12px 16px;
  background: rgba(224, 85, 85, 0.1);
  border: 1px solid rgba(224, 85, 85, 0.25);
  border-radius: var(--radius-sm);
  color: #f87171;
  font-size: 0.88rem;
  margin-bottom: 16px;
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .table-header,
  .table-row { grid-template-columns: 1.5fr 1fr 1fr; }
  .table-header > span:nth-child(2),
  .table-row > span:nth-child(2) { display: none; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .page-wrap { padding: 24px 16px 60px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .table-header,
  .table-row { grid-template-columns: 1fr 1fr; }
  .table-header > span:nth-child(3),
  .table-row > span:nth-child(3) { display: none; }
  .auth-card { padding: 28px 24px; }
  .form-actions { flex-direction: column; }
  .form-actions .btn-ghost { text-align: center; justify-content: center; }
}

/* ---- Plan badges (nav) ---- */
.nav-plan-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 100px;
  white-space: nowrap;
}

.badge-pro {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(34, 214, 138, 0.25);
}

.badge-trial {
  background: rgba(34, 214, 138, 0.08);
  color: var(--accent);
  border: 1px solid rgba(34, 214, 138, 0.2);
}

.badge-free {
  background: rgba(139, 151, 176, 0.08);
  color: var(--fg-muted);
  border: 1px solid var(--border);
}

.badge-pastdue {
  background: rgba(251, 146, 60, 0.1);
  color: #fb923c;
  border: 1px solid rgba(251, 146, 60, 0.25);
}

.badge-cancelled {
  background: rgba(224, 85, 85, 0.08);
  color: #f87171;
  border: 1px solid rgba(224, 85, 85, 0.2);
}

/* ---- Demo pill & banner ---- */
.badge-demo {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(139, 151, 176, 0.12);
  color: var(--fg-muted);
  border: 1px solid var(--border);
  vertical-align: middle;
  margin-left: 6px;
  text-transform: uppercase;
}

.demo-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(34, 214, 138, 0.06);
  border: 1px solid rgba(34, 214, 138, 0.2);
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.demo-banner-body {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.demo-banner-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.demo-banner-text {
  font-size: 0.9rem;
  color: var(--fg-muted);
  line-height: 1.5;
}

.demo-banner-text strong {
  color: var(--fg);
}

.demo-banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
