/* OwlStack App Styles */
:root {
  --bg-deep: #0a0e1a;
  --bg-card: #111827;
  --bg-glow: #1a1f35;
  --bg-input: #1e293b;
  --amber: #f59e0b;
  --amber-soft: #fbbf24;
  --amber-dim: rgba(245, 158, 11, 0.15);
  --amber-hover: #d97706;
  --green: #22c55e;
  --blue: #3b82f6;
  --red: #ef4444;
  --purple: #a855f7;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: rgba(148, 163, 184, 0.08);
  --border-focus: rgba(245, 158, 11, 0.4);
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3, h4, h5 { font-family: 'Space Grotesk', sans-serif; }
a { color: var(--amber); text-decoration: none; }
a:hover { color: var(--amber-soft); }

/* ==================== APP NAV ==================== */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 14, 26, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
}

.app-nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 32px;
}

.app-nav .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text-primary);
  text-decoration: none;
}

.app-nav .logo-icon {
  width: 32px; height: 32px;
  background: var(--amber);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}

.nav-links {
  display: flex;
  gap: 4px;
  flex: 1;
}

.nav-links a {
  padding: 8px 16px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}

.nav-links a:hover, .nav-links a.active {
  color: var(--text-primary);
  background: rgba(245, 158, 11, 0.08);
}

.nav-links a.active { color: var(--amber); }

.nav-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-user .user-name {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.btn-logout {
  padding: 6px 14px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'DM Sans', sans-serif;
}

.btn-logout:hover {
  border-color: var(--red);
  color: var(--red);
}

/* ==================== LAYOUT ==================== */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px;
}

.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-header p {
  color: var(--text-secondary);
  margin-top: 8px;
}

/* ==================== CARDS ==================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
}

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

.card-title {
  font-size: 1.15rem;
  font-weight: 600;
}

/* ==================== FORMS ==================== */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-primary);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  transition: border-color 0.2s;
  outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--border-focus);
}

.form-input::placeholder, .form-textarea::placeholder {
  color: var(--text-muted);
}

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

.form-select {
  cursor: pointer;
  appearance: none;
  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='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

.form-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 10px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

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

.btn-primary {
  background: var(--amber);
  color: #000;
}

.btn-primary:hover:not(:disabled) {
  background: var(--amber-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-glow);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  border-color: rgba(245, 158, 11, 0.3);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 16px;
}

.btn-ghost:hover { color: var(--text-primary); }

.btn-full { width: 100%; }

.btn-sm {
  padding: 8px 16px;
  font-size: 0.85rem;
  border-radius: 8px;
}

/* ==================== BADGES ==================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-inquiry { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.badge-lead { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.badge-invoice { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.badge-spam { background: rgba(100, 116, 139, 0.15); color: #94a3b8; }
.badge-urgent { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.badge-personal { background: rgba(168, 85, 247, 0.15); color: #c084fc; }

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

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

.stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--amber);
  line-height: 1;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ==================== EMAIL LIST ==================== */
.email-item {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s;
}

.email-item:hover { background: rgba(245, 158, 11, 0.03); }
.email-item:last-child { border-bottom: none; }

.email-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
}

.email-icon.inquiry { background: rgba(59, 130, 246, 0.12); }
.email-icon.lead { background: rgba(34, 197, 94, 0.12); }
.email-icon.invoice { background: rgba(245, 158, 11, 0.12); }
.email-icon.spam { background: rgba(100, 116, 139, 0.12); }
.email-icon.urgent { background: rgba(239, 68, 68, 0.12); }
.email-icon.personal { background: rgba(168, 85, 247, 0.12); }

.email-content {
  flex: 1;
  min-width: 0;
}

.email-from {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 2px;
}

.email-subject {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-summary {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.email-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.email-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ==================== FILTER TABS ==================== */
.filter-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.filter-tab {
  padding: 8px 16px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-tab:hover {
  color: var(--text-secondary);
  background: var(--bg-glow);
}

.filter-tab.active {
  color: var(--amber);
  background: var(--amber-dim);
  border-color: rgba(245, 158, 11, 0.2);
}

.filter-tab .count {
  margin-left: 4px;
  font-size: 0.75rem;
  opacity: 0.7;
}

/* ==================== BRIEFING ==================== */
.briefing-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 32px;
}

.briefing-banner {
  padding: 20px 28px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(59, 130, 246, 0.04));
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
}

.briefing-status {
  width: 10px; height: 10px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.briefing-label {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.briefing-date {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.briefing-body {
  padding: 28px;
}

.briefing-summary {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.briefing-highlights {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 28px;
}

.highlight-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px;
  background: var(--bg-glow);
  border-radius: 10px;
}

.highlight-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
  line-height: 1;
}

.highlight-text { flex: 1; }

.highlight-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 2px;
}

.highlight-detail {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.action-items {
  border-top: 1px solid var(--border);
  padding-top: 24px;
}

.action-items h4 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--amber);
  margin-bottom: 16px;
}

.action-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.action-item:last-child { border-bottom: none; }

.action-priority {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  flex-shrink: 0;
  margin-top: 2px;
}

.action-priority.high {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.action-priority.medium {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.action-text { flex: 1; }

.action-title {
  font-weight: 500;
  font-size: 0.9rem;
}

.action-reason {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ==================== AUTH PAGES ==================== */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card { width: 100%; max-width: 420px; }

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 40px;
}

.auth-logo .logo-icon {
  width: 48px; height: 48px;
  background: var(--amber);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
}

.auth-logo span {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
}

.auth-title {
  text-align: center;
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.auth-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 32px;
}

.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.auth-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #f87171;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 20px;
  display: none;
}

/* ==================== ONBOARDING ==================== */
.onboarding-container {
  max-width: 600px;
  margin: 0 auto;
  padding: 60px 24px;
}

.step-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 48px;
}

.step-dot {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  border: 2px solid var(--border);
  color: var(--text-muted);
  transition: all 0.3s;
}

.step-dot.active {
  border-color: var(--amber);
  background: var(--amber);
  color: #000;
}

.step-dot.completed {
  border-color: var(--green);
  background: rgba(34, 197, 94, 0.15);
  color: var(--green);
}

.step-line {
  width: 60px;
  height: 2px;
  background: var(--border);
  transition: background 0.3s;
}

.step-line.active { background: var(--amber); }
.step-line.completed { background: var(--green); }

.step-content {
  display: none;
}

.step-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

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

.step-title {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.step-subtitle {
  color: var(--text-secondary);
  margin-bottom: 32px;
}

/* Toggle Switch */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-glow);
  border-radius: 10px;
  margin-bottom: 16px;
}

.toggle-info { flex: 1; margin-right: 16px; }

.toggle-title {
  font-weight: 500;
  font-size: 0.9rem;
}

.toggle-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.toggle {
  position: relative;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-input);
  border-radius: 26px;
  transition: 0.3s;
}

.toggle-slider:before {
  content: '';
  position: absolute;
  height: 20px; width: 20px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}

.toggle input:checked + .toggle-slider { background: var(--amber); }
.toggle input:checked + .toggle-slider:before { transform: translateX(22px); }

/* ==================== LOADING ==================== */
.loading-spinner {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
}

.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-lg {
  width: 32px; height: 32px;
  border-width: 3px;
}

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

/* ==================== EMPTY STATE ==================== */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}

.empty-state .icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state h3 { color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { max-width: 400px; margin: 0 auto 24px; }

/* ==================== MODAL ==================== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 32px;
  animation: fadeIn 0.2s ease;
}

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

.modal-title {
  font-size: 1.2rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.modal-close:hover { color: var(--text-primary); }

/* ==================== EMAIL DETAIL ==================== */
.email-detail {
  padding: 0;
}

.email-detail-header {
  padding: 24px 28px;
  border-bottom: 1px solid var(--border);
}

.email-detail-from {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 4px;
}

.email-detail-address {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.email-detail-subject {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 12px;
}

.email-detail-body {
  padding: 24px 28px;
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.8;
  white-space: pre-wrap;
  border-bottom: 1px solid var(--border);
}

.email-detail-ai {
  padding: 24px 28px;
  background: var(--bg-glow);
}

.ai-section-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--amber);
  font-weight: 600;
  margin-bottom: 12px;
  font-family: 'Space Grotesk', sans-serif;
}

.ai-response {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.7;
  padding: 16px;
  background: var(--bg-card);
  border-radius: 10px;
  border: 1px solid var(--border);
}

/* ==================== GENERATE BRIEFING CTA ==================== */
.generate-cta {
  text-align: center;
  padding: 48px 24px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.06), rgba(59, 130, 246, 0.03));
  border: 1px dashed rgba(245, 158, 11, 0.2);
  border-radius: 16px;
  margin-bottom: 32px;
}

.generate-cta .icon {
  font-size: 2.5rem;
  margin-bottom: 16px;
}

.generate-cta h3 {
  font-size: 1.2rem;
  margin-bottom: 8px;
}

.generate-cta p {
  color: var(--text-secondary);
  font-size: 0.92rem;
  max-width: 400px;
  margin: 0 auto 24px;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
  .app-nav-inner { gap: 16px; }
  .nav-links { gap: 0; }
  .nav-links a { padding: 6px 10px; font-size: 0.8rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .container { padding: 24px 16px; }
  .card { padding: 24px; }
  .briefing-body { padding: 20px; }
  .email-item { padding: 14px 16px; }
  .step-line { width: 30px; }
}

@media (max-width: 480px) {
  .nav-user .user-name { display: none; }
  .filter-tabs { gap: 2px; }
  .filter-tab { padding: 6px 10px; font-size: 0.8rem; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 1.6rem; }
}
