/* ==========================================================================
   Goodjuju Web App — Consolidated Stylesheet
   Colors: Orange #ff7c05, Dark #1a1a2e, BG #f8f9fb
   Font: Inter (Google Fonts)
   ========================================================================== */

/* --- Reset & Base --- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body { font-family: 'Inter', sans-serif; background: #f8f9fb; color: #1a1a2e; line-height: 1.5; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
input, select, textarea, button { font-family: inherit; }

/* --- Sidebar --- */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; width: 240px;
  background: #1a1a2e; color: #fff; padding: 24px 0;
  display: flex; flex-direction: column; z-index: 50;
}
.sidebar-logo {
  padding: 0 24px 28px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo .dot { width: 28px; height: 28px; background: #ff7c05; border-radius: 50%; flex-shrink: 0; }
.sidebar-mark { width: 32px; height: 32px; flex-shrink: 0; border-radius: 6px; }
.sidebar-logo span { font-weight: 700; font-size: 15px; letter-spacing: -0.3px; }
.sidebar nav { padding: 20px 0; flex: 1; }
.sidebar nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 24px; color: rgba(255,255,255,0.55); text-decoration: none;
  font-size: 14px; font-weight: 500; transition: all 0.15s;
}
.sidebar nav a:hover { color: #fff; background: rgba(255,255,255,0.05); }
.sidebar nav a.active { color: #fff; background: rgba(255,124,5,0.15); border-right: 3px solid #ff7c05; }
.sidebar nav a .icon { width: 20px; text-align: center; font-size: 16px; }
.sidebar .user-block {
  padding: 16px 24px; border-top: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 10px;
}
.sidebar .user-block .avatar {
  width: 32px; height: 32px; background: #ff7c05; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.sidebar .user-block .name { font-size: 13px; font-weight: 500; }
.sidebar .user-block .role { font-size: 11px; color: rgba(255,255,255,0.4); }
.sidebar .user-block .logout {
  margin-left: auto; font-size: 12px; color: rgba(255,255,255,0.35);
  cursor: pointer; transition: color 0.15s;
}
.sidebar .user-block .logout:hover { color: #ff7c05; }

/* --- Main Content Area --- */
.main { margin-left: 240px; padding: 32px 40px; min-height: 100vh; }

/* --- Top Bar --- */
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 32px; }
.topbar h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.5px; }
.topbar-actions { display: flex; gap: 12px; align-items: center; }

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: 8px; font-size: 14px;
  font-weight: 600; cursor: pointer; border: none; transition: all 0.15s;
  text-decoration: none;
}
.btn-primary { background: #ff7c05; color: #fff; }
.btn-primary:hover { background: #e86e00; }
.btn-outline { background: #fff; color: #1a1a2e; border: 1px solid #ddd; }
.btn-outline:hover { border-color: #bbb; background: #fafafa; }
.btn-danger { background: #fee2e2; color: #dc2626; }
.btn-danger:hover { background: #fecaca; }
.btn-success { background: #dcfce7; color: #16a34a; }
.btn-success:hover { background: #bbf7d0; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-icon { padding: 8px 12px; }
.btn:disabled, .btn.disabled { opacity: 0.5; cursor: not-allowed; }

/* --- Stat Cards --- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 32px; }
.stat-card {
  background: #fff; border-radius: 12px; padding: 20px 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.stat-card .label { font-size: 12px; color: #888; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .value { font-size: 28px; font-weight: 700; margin-top: 4px; }
.stat-card .sub { font-size: 12px; color: #888; margin-top: 2px; }
.stat-card .value.orange { color: #ff7c05; }
.stat-card .value.green { color: #22c55e; }
.stat-card .value.red { color: #ef4444; }

/* --- Section Headers & Tabs --- */
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.section-header h2 { font-size: 17px; font-weight: 600; }
.tabs { display: flex; gap: 4px; }
.tab {
  padding: 6px 14px; border-radius: 6px; font-size: 13px; font-weight: 500;
  cursor: pointer; color: #666; background: transparent; border: none;
  text-decoration: none; transition: all 0.15s;
}
.tab:hover { background: #eee; }
.tab.active { background: #1a1a2e; color: #fff; }

/* --- Tables --- */
.table-wrap {
  background: #fff; border-radius: 12px; overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; padding: 12px 20px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px; color: #888;
  background: #fafafa; border-bottom: 1px solid #eee;
}
td { padding: 14px 20px; font-size: 14px; border-bottom: 1px solid #f3f3f3; }
tr:last-child td { border-bottom: none; }
tr:hover { background: #fafbfc; }

.client-name { font-weight: 600; }
.topic-cell { max-width: 280px; }
.topic-cell .topic { font-weight: 500; }
.topic-cell .keyword { font-size: 12px; color: #888; margin-top: 2px; }

.action-link { color: #ff7c05; font-weight: 600; font-size: 13px; cursor: pointer; text-decoration: none; }
.action-link:hover { text-decoration: underline; }

.ai-score { font-weight: 700; }
.ai-score.pass { color: #22c55e; }
.ai-score.fail { color: #ef4444; }
.ai-score.pending { color: #aaa; }

/* --- Badges --- */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge-waiting { background: #fff3e0; color: #e65100; }
.badge-writing { background: #e3f2fd; color: #1565c0; }
.badge-scanning { background: #f3e5f5; color: #7b1fa2; }
.badge-done { background: #e8f5e9; color: #2e7d32; }
.badge-review { background: #fff8e1; color: #f57f17; }
.badge-failed { background: #fee2e2; color: #dc2626; }
.badge-complete { background: #e8f5e9; color: #2e7d32; }
.badge-pending { background: #fff8e1; color: #f57f17; }
.badge-not-sent { background: #f3f4f6; color: #6b7280; }
.badge-approved { background: #e8f5e9; color: #2e7d32; }
.badge-rejected { background: #fee2e2; color: #dc2626; }
.badge-enriching { background: #e3f2fd; color: #1565c0; }

/* --- Cards --- */
.card {
  background: #fff; border-radius: 12px; padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.card + .card { margin-top: 16px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-header h3 { font-size: 16px; font-weight: 600; }

/* --- Info Grid (key-value display) --- */
.info-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.info-item .info-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: #888; margin-bottom: 2px; }
.info-item .info-value { font-size: 14px; font-weight: 500; }

/* --- Modals --- */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  z-index: 100; align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
  background: #fff; border-radius: 16px; padding: 32px; width: 520px;
  max-height: 80vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.modal h2 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.modal .subtitle { font-size: 14px; color: #888; margin-bottom: 24px; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }

/* --- Forms --- */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #1a1a2e;
}
.form-group .hint { font-size: 12px; color: #888; margin-top: 4px; }
.form-group select,
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="url"],
.form-group input[type="tel"],
.form-group textarea {
  width: 100%; padding: 10px 14px; border: 1px solid #ddd; border-radius: 8px;
  font-size: 14px; font-family: 'Inter', sans-serif; transition: border-color 0.15s;
  background: #fff;
}
.form-group select:focus,
.form-group input:focus,
.form-group textarea:focus {
  outline: none; border-color: #ff7c05; box-shadow: 0 0 0 3px rgba(255,124,5,0.1);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Checkbox/Multi-select grid */
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.checkbox-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border: 1px solid #eee; border-radius: 8px; cursor: pointer; transition: all 0.15s;
  font-size: 14px;
}
.checkbox-item:hover { border-color: #ff7c05; background: #fff8f0; }
.checkbox-item input[type="checkbox"] { accent-color: #ff7c05; width: 16px; height: 16px; }

/* --- Flash Messages --- */
.flash-messages { margin-bottom: 24px; }
.flash {
  padding: 12px 20px; border-radius: 8px; font-size: 14px; font-weight: 500;
  margin-bottom: 8px; display: flex; align-items: center; gap: 10px;
}
.flash-success { background: #e8f5e9; color: #2e7d32; }
.flash-error { background: #fee2e2; color: #dc2626; }
.flash-warning { background: #fff8e1; color: #f57f17; }
.flash-info { background: #e3f2fd; color: #1565c0; }

/* --- Empty State --- */
.empty-state {
  text-align: center; padding: 48px 24px; color: #888;
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; margin-bottom: 16px; }

/* --- Approval Cards --- */
.approval-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; }
.approval-card {
  background: #fff; border-radius: 12px; padding: 20px 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04); border-left: 4px solid #ff7c05;
}
.approval-card.reviewed { border-left-color: #ddd; opacity: 0.7; }
.approval-card .approval-client { font-size: 12px; color: #888; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.approval-card .approval-topic { font-size: 16px; font-weight: 600; margin: 6px 0; }
.approval-card .approval-type { font-size: 13px; color: #666; margin-bottom: 12px; }
.approval-card .approval-meta { font-size: 12px; color: #888; margin-bottom: 14px; }
.approval-card .approval-actions { display: flex; gap: 10px; }

/* --- Login Page --- */
.login-wrapper {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: #1a1a2e;
}
.login-card {
  background: #fff; border-radius: 16px; padding: 40px; width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.login-card .login-logo {
  display: flex; align-items: center; gap: 10px; margin-bottom: 32px;
  justify-content: center;
}
.login-card .login-logo .dot { width: 32px; height: 32px; background: #ff7c05; border-radius: 50%; }
.login-mark { width: 44px; height: 44px; border-radius: 10px; }
.login-card .login-logo span { font-weight: 700; font-size: 18px; color: #1a1a2e; }
.login-card h1 { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 4px; }
.login-card .login-sub { font-size: 14px; color: #888; text-align: center; margin-bottom: 28px; }
.login-card .form-group { margin-bottom: 16px; }
.login-card .btn-primary { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }
.login-error { background: #fee2e2; color: #dc2626; padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; text-align: center; }

/* --- Intake Form (Standalone) --- */
.intake-wrapper { background: #f8f9fb; min-height: 100vh; }
.intake-header {
  background: #1a1a2e; padding: 24px 40px; display: flex; align-items: center; gap: 12px;
}
.intake-header .dot { width: 28px; height: 28px; background: #ff7c05; border-radius: 50%; }
.intake-mark { width: 32px; height: 32px; border-radius: 6px; }
.intake-header span { font-weight: 700; font-size: 16px; color: #fff; }
.intake-body { max-width: 780px; margin: 32px auto; padding: 0 24px 60px; }
.intake-body h1 { font-size: 26px; font-weight: 700; margin-bottom: 4px; }
.intake-body .intake-sub { font-size: 15px; color: #666; margin-bottom: 32px; }

.intake-section {
  background: #fff; border-radius: 12px; padding: 28px 32px; margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.intake-section h2 {
  font-size: 17px; font-weight: 700; margin-bottom: 4px;
  padding-bottom: 12px; border-bottom: 2px solid #ff7c05;
  display: inline-block;
}
.intake-section .section-desc { font-size: 13px; color: #888; margin-bottom: 20px; }

/* Repeatable rows */
.repeatable-group { margin-bottom: 12px; }
.repeatable-row {
  display: flex; gap: 12px; align-items: end; margin-bottom: 8px;
}
.repeatable-row .form-group { flex: 1; margin-bottom: 0; }
.repeatable-row .btn-remove {
  padding: 10px 14px; background: none; border: 1px solid #eee; border-radius: 8px;
  cursor: pointer; color: #999; font-size: 16px; transition: all 0.15s;
}
.repeatable-row .btn-remove:hover { color: #dc2626; border-color: #dc2626; }
.btn-add-row {
  background: none; border: 1px dashed #ddd; border-radius: 8px; padding: 10px;
  width: 100%; text-align: center; cursor: pointer; color: #888;
  font-size: 13px; font-weight: 500; transition: all 0.15s;
}
.btn-add-row:hover { border-color: #ff7c05; color: #ff7c05; }

/* --- Thank-you / Not Found (Standalone) --- */
.standalone-center {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; background: #f8f9fb;
  text-align: center; padding: 40px;
}
.standalone-center .dot-big { width: 48px; height: 48px; background: #ff7c05; border-radius: 50%; margin-bottom: 20px; }
.standalone-center h1 { font-size: 28px; font-weight: 700; margin-bottom: 8px; }
.standalone-center p { font-size: 15px; color: #666; max-width: 440px; margin-bottom: 24px; line-height: 1.6; }

/* --- Detail Page Timeline --- */
.timeline { margin-top: 16px; }
.timeline-item {
  display: flex; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid #f3f3f3; font-size: 14px;
}
.timeline-item:last-child { border-bottom: none; }
.timeline-item .tl-time { font-size: 12px; color: #888; width: 140px; flex-shrink: 0; }
.timeline-item .tl-event { font-weight: 500; }

/* --- Cluster Plan List --- */
.plan-list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid #f3f3f3;
}
.plan-list-item:last-child { border-bottom: none; }
.plan-list-item .plan-client { font-weight: 600; }
.plan-list-item .plan-date { font-size: 13px; color: #888; }

/* --- HTMX indicator --- */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-block; }
.htmx-request.htmx-indicator { display: inline-block; }
.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid #ddd; border-top-color: #ff7c05;
  border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Responsive --- */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 20px; }
  .stats { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; gap: 12px; align-items: flex-start; }
  .approval-cards { grid-template-columns: 1fr; }
}
