/* ── Koru App Styles ── */
/* Matches the landing page design system */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=DM+Sans:wght@400;500&display=swap');

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

:root {
  --deep: #0a1a0f;
  --forest: #1a3a2a;
  --emerald: #2d8a5e;
  --mint: #5eda9e;
  --gold: #d4a847;
  --cream: #f5f0e8;
  --white: #fefefe;
  --text: #2a2a2a;
  --muted: #6b7c72;
  --danger: #e85d5d;
  --card-bg: rgba(255,255,255,0.03);
  --card-border: rgba(255,255,255,0.08);
  --sidebar-w: 240px;
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--cream);
  background: var(--deep);
  min-height: 100vh;
}

h1, h2, h3, h4 {
  font-family: 'Space Grotesk', sans-serif;
}

a { color: var(--mint); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #0d1f14 0%, #0a1a0f 100%);
  border-right: 1px solid var(--card-border);
  padding: 24px 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
}

.sidebar-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--white);
  padding: 0 24px;
  margin-bottom: 32px;
}

.sidebar-logo span {
  color: var(--mint);
  font-size: 0.65rem;
  font-weight: 500;
  margin-left: 8px;
  vertical-align: middle;
  background: rgba(93,218,158,0.1);
  padding: 2px 8px;
  border-radius: 100px;
}

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

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,0.5);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.nav-link:hover {
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.8);
  text-decoration: none;
}

.nav-link.active {
  background: rgba(93,218,158,0.1);
  color: var(--mint);
}

.nav-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--card-border);
}

.sidebar-user {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.4);
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-logout {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.3);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}
.btn-logout:hover { color: var(--danger); }

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 32px 40px;
  max-width: 1000px;
}

/* ── Auth pages ── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #0a1a0f 0%, #122218 40%, #1a3a2a 100%);
}

.auth-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 48px;
  width: 100%;
  max-width: 420px;
}

.auth-card h1 {
  font-size: 1.8rem;
  color: var(--white);
  margin-bottom: 8px;
}

.auth-card .subtitle {
  color: rgba(255,255,255,0.4);
  font-size: 0.95rem;
  margin-bottom: 32px;
}

/* ── Forms ── */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: rgba(255,255,255,0.5);
  margin-bottom: 6px;
  letter-spacing: 0.3px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  color: var(--white);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.form-input:focus {
  border-color: var(--emerald);
}

.form-input::placeholder {
  color: rgba(255,255,255,0.2);
}

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

select.form-input {
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

select.form-input option {
  background: var(--deep);
  color: var(--white);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--emerald);
  color: var(--white);
}
.btn-primary:hover { background: #35a06c; }

.btn-secondary {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.7);
  border: 1px solid var(--card-border);
}
.btn-secondary:hover { background: rgba(255,255,255,0.1); }

.btn-danger {
  background: rgba(232,93,93,0.15);
  color: var(--danger);
  border: 1px solid rgba(232,93,93,0.2);
}
.btn-danger:hover { background: rgba(232,93,93,0.25); }

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

.btn-full { width: 100%; }

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Page Header ── */
.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 1.6rem;
  color: var(--white);
  margin-bottom: 4px;
}

.page-header p {
  color: rgba(255,255,255,0.4);
  font-size: 0.9rem;
}

/* ── Cards ── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--white);
}

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

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

.stat-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--mint);
}

.stat-value.gold { color: var(--gold); }

/* ── Conversation List ── */
.convo-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.convo-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
}

.convo-item:hover {
  background: rgba(255,255,255,0.05);
  border-color: rgba(93,218,158,0.2);
}

.convo-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--emerald), var(--forest));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--white);
  flex-shrink: 0;
}

.convo-body {
  flex: 1;
  min-width: 0;
}

.convo-name {
  font-weight: 500;
  color: var(--white);
  font-size: 0.95rem;
}

.convo-subject {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.5);
  margin-top: 2px;
}

.convo-preview {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.3);
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.convo-meta {
  text-align: right;
  flex-shrink: 0;
}

.convo-time {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.3);
}

.convo-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 500;
  margin-top: 4px;
}

.badge-active { background: rgba(93,218,158,0.15); color: var(--mint); }
.badge-draft { background: rgba(212,168,71,0.15); color: var(--gold); }
.badge-sent { background: rgba(93,218,158,0.15); color: var(--mint); }
.badge-paid { background: rgba(93,218,158,0.25); color: #4ece8f; }
.badge-overdue { background: rgba(232,93,93,0.15); color: var(--danger); }
.badge-cancelled { background: rgba(255,255,255,0.05); color: rgba(255,255,255,0.3); }

/* ── Message Thread ── */
.message-thread {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 20px;
}

.message-bubble {
  max-width: 75%;
  padding: 14px 18px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.6;
  position: relative;
}

.message-inbound {
  align-self: flex-start;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--card-border);
  color: rgba(255,255,255,0.8);
}

.message-outbound {
  align-self: flex-end;
  background: rgba(45,138,94,0.15);
  border: 1px solid rgba(45,138,94,0.25);
  color: rgba(255,255,255,0.85);
}

.message-meta {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.3);
  margin-top: 6px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.ai-badge {
  background: rgba(212,168,71,0.2);
  color: var(--gold);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 600;
}

.pending-badge {
  background: rgba(232,93,93,0.15);
  color: var(--danger);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 600;
}

/* ── Reply Box ── */
.reply-box {
  margin-top: 24px;
  padding: 20px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
}

.reply-box textarea {
  width: 100%;
  min-height: 80px;
  margin-bottom: 12px;
}

.reply-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ── Invoice Table ── */
.invoice-table {
  width: 100%;
  border-collapse: collapse;
}

.invoice-table th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--card-border);
}

.invoice-table td {
  padding: 14px 16px;
  font-size: 0.9rem;
  color: rgba(255,255,255,0.7);
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.invoice-table tr:hover td {
  background: rgba(255,255,255,0.02);
}

.amount {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  color: var(--white);
}

/* ── Onboarding ── */
.onboarding-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  background: linear-gradient(160deg, #0a1a0f 0%, #122218 40%, #1a3a2a 100%);
}

.onboarding-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 48px;
  width: 100%;
  max-width: 600px;
}

.onboarding-card h1 {
  font-size: 1.6rem;
  color: var(--white);
  margin-bottom: 4px;
}

.onboarding-card .subtitle {
  color: rgba(255,255,255,0.4);
  font-size: 0.9rem;
  margin-bottom: 32px;
}

.step-indicator {
  display: flex;
  gap: 8px;
  margin-bottom: 32px;
}

.step-dot {
  width: 32px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.1);
}

.step-dot.active {
  background: var(--mint);
}

.step-dot.done {
  background: var(--emerald);
}

/* Services list */
.services-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.service-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--card-border);
  border-radius: 8px;
}

.service-item .service-name {
  flex: 1;
  color: var(--white);
  font-size: 0.9rem;
}

.service-item .service-desc {
  flex: 2;
  color: rgba(255,255,255,0.5);
  font-size: 0.8rem;
}

.service-item .remove-service {
  cursor: pointer;
  color: rgba(255,255,255,0.3);
  font-size: 1.2rem;
  background: none;
  border: none;
  padding: 0 4px;
}
.service-item .remove-service:hover { color: var(--danger); }

.add-service-row {
  display: flex;
  gap: 8px;
}

.add-service-row .form-input { flex: 1; }

/* Availability checkboxes */
.day-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.day-chip {
  padding: 6px 14px;
  border-radius: 100px;
  border: 1px solid var(--card-border);
  font-size: 0.8rem;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  background: transparent;
  transition: all 0.15s;
}

.day-chip.selected {
  border-color: var(--emerald);
  background: rgba(45,138,94,0.15);
  color: var(--mint);
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: rgba(255,255,255,0.3);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state h3 {
  color: rgba(255,255,255,0.5);
  font-size: 1.1rem;
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 0.9rem;
  max-width: 400px;
  margin: 0 auto 20px;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  z-index: 100;
  animation: slideUp 0.3s ease;
}

.toast-success { background: var(--emerald); color: var(--white); }
.toast-error { background: var(--danger); color: var(--white); }

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ── Back link ── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: rgba(255,255,255,0.4);
  font-size: 0.85rem;
  margin-bottom: 20px;
  cursor: pointer;
}
.back-link:hover { color: var(--mint); text-decoration: none; }

/* ── Loading ── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: rgba(255,255,255,0.3);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: var(--mint);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 10px;
}

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

/* ── Test Email Box ── */
.test-email-box {
  background: rgba(212,168,71,0.08);
  border: 1px solid rgba(212,168,71,0.2);
  border-radius: 12px;
  padding: 20px;
  margin-top: 24px;
}

.test-email-box h3 {
  color: var(--gold);
  font-size: 0.9rem;
  margin-bottom: 12px;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(4px);
}

.modal-card {
  background: #111d15;
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-card h2 {
  font-size: 1.2rem;
  color: var(--white);
  margin-bottom: 20px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 20px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .message-bubble { max-width: 90%; }
  .auth-card, .onboarding-card { padding: 32px 24px; }
}
