/* ============================================
   4USENDER App CSS — Components & Layout
   Font (Inter) is loaded via <link> in base.html — do NOT @import here
   (was blocked by CSP style-src before the Caddyfile fix and is redundant).
   ============================================ */

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary, #0a0a0a);
  color: var(--text-primary, #fafafa);
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

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

.main-content {
  flex: 1;
  padding: 24px 32px;
  max-width: 1400px;
  overflow-x: hidden;
}

/* === Page Header === */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}

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

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-primary, #3b82f6);
  color: white;
}
.btn-primary:hover {
  background: #2563eb;
}

.btn-success { background: #22c55e; color: white; }
.btn-danger { background: #ef4444; color: white; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary, #a1a1aa);
  border: 1px solid var(--border-primary, #262626);
}
.btn-ghost:hover {
  background: var(--bg-tertiary, #1e1e1e);
  color: var(--text-primary, #fafafa);
}

.btn-sm { padding: 4px 10px; font-size: 0.8125rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }

.btn-group {
  display: inline-flex;
  gap: 0;
}
.btn-group .btn {
  border-radius: 0;
}
.btn-group .btn:first-child { border-radius: 8px 0 0 8px; }
.btn-group .btn:last-child { border-radius: 0 8px 8px 0; }

/* === Cards === */
.card {
  background: var(--bg-secondary, #141414);
  border: 1px solid var(--border-primary, #262626);
  border-radius: 12px;
  padding: 20px;
}

.stat-card {
  background: var(--bg-secondary, #141414);
  border: 1px solid var(--border-primary, #262626);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
}
.stat-card .stat-label {
  font-size: 0.8125rem;
  color: var(--text-secondary, #a1a1aa);
}
.stat-card .stat-change {
  font-size: 0.75rem;
  margin-top: 4px;
}
.stat-change.positive { color: #22c55e; }
.stat-change.negative { color: #ef4444; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

/* === Tables === */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.data-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-secondary, #a1a1aa);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-primary, #262626);
}
.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border-primary, #262626);
  vertical-align: middle;
}
.data-table tr:hover td {
  background: var(--bg-tertiary, #1e1e1e);
}

/* === Badges === */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}
.badge-primary { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.badge-success { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.badge-secondary { background: rgba(161, 161, 170, 0.15); color: #a1a1aa; }
.badge-sm { padding: 1px 6px; font-size: 0.6875rem; }

.badge-new { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-interested { background: rgba(34,197,94,0.15); color: #4ade80; }
.badge-not_interested { background: rgba(239,68,68,0.15); color: #f87171; }
.badge-meeting_booked { background: rgba(168,85,247,0.15); color: #c084fc; }
.badge-out_of_office { background: rgba(245,158,11,0.15); color: #fbbf24; }

/* === Forms === */
.form-group {
  margin-bottom: 16px;
}
.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary, #a1a1aa);
  margin-bottom: 6px;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-primary, #0a0a0a);
  border: 1px solid var(--border-primary, #262626);
  border-radius: 8px;
  color: var(--text-primary, #fafafa);
  font-size: 0.875rem;
  transition: border-color 0.15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--accent-primary, #3b82f6);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.form-textarea { min-height: 120px; resize: vertical; }

/* === Inbox === */
.inbox-list {
  display: flex;
  flex-direction: column;
}
.inbox-item {
  display: grid;
  grid-template-columns: 24px 200px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-primary, #262626);
  cursor: pointer;
  transition: background 0.1s;
}
.inbox-item:hover {
  background: var(--bg-tertiary, #1e1e1e);
}
.inbox-unread {
  background: rgba(59, 130, 246, 0.03);
}
.inbox-unread .inbox-item-subject {
  font-weight: 600;
}
.inbox-item-from {
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inbox-item-subject {
  font-size: 0.875rem;
  color: var(--text-secondary, #a1a1aa);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inbox-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-tertiary, #71717a);
  white-space: nowrap;
}
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-blue { background: #3b82f6; }

.inbox-detail-panel {
  margin-top: 24px;
  padding: 24px;
  background: var(--bg-secondary, #141414);
  border: 1px solid var(--border-primary, #262626);
  border-radius: 12px;
  display: none;
}
.inbox-detail-panel:not(:empty) {
  display: block;
}

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-secondary, #a1a1aa);
}
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 1.125rem; margin-bottom: 8px; color: var(--text-primary, #fafafa); }
.empty-state p { max-width: 400px; margin: 0 auto; line-height: 1.6; }

/* === Pagination === */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-primary, #262626);
}
.pagination-info {
  font-size: 0.875rem;
  color: var(--text-secondary, #a1a1aa);
}

/* === Tabs === */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-primary, #262626);
  margin-bottom: 24px;
}
.tab {
  padding: 10px 16px;
  font-size: 0.875rem;
  color: var(--text-secondary, #a1a1aa);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.tab:hover { color: var(--text-primary, #fafafa); }
.tab.active {
  color: var(--accent-primary, #3b82f6);
  border-bottom-color: var(--accent-primary, #3b82f6);
}

/* === Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal {
  background: var(--bg-secondary, #141414);
  border: 1px solid var(--border-primary, #262626);
  border-radius: 12px;
  padding: 24px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal-header h2 { font-size: 1.125rem; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary, #a1a1aa);
  cursor: pointer;
  font-size: 1.25rem;
}

/* === Skeleton Loader ===
   Moved to components/skeleton.css (Phase 2 wave 3) — loaded explicitly
   by base.html. This keeps skeleton + spinner + htmx-indicator in one file. */

/* === Text Utilities === */
.text-muted { color: var(--text-secondary, #a1a1aa); }
.text-success { color: #22c55e; }
.text-danger { color: #ef4444; }
.text-warning { color: #f59e0b; }
.text-sm { font-size: 0.8125rem; }
.text-xs { font-size: 0.75rem; }

/* === Mobile Responsive === */
@media (max-width: 768px) {
  .app-layout { flex-direction: column; }

  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    bottom: 0;
    z-index: 50;
    transition: left 0.3s ease;
    width: 280px;
  }
  .sidebar.open { left: 0; }

  .main-content { padding: 16px; }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .data-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .inbox-item {
    grid-template-columns: 16px 1fr;
    grid-template-rows: auto auto;
    gap: 4px 8px;
    padding: 10px 12px;
  }
  .inbox-item-from { grid-column: 2; }
  .inbox-item-subject { grid-column: 2; }
  .inbox-item-meta { grid-column: 2; }

  .btn-group {
    flex-wrap: wrap;
  }

  .modal { width: 95%; max-height: 90vh; }

  /* Mobile hamburger */
  .mobile-menu-btn {
    display: block;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 60;
    background: var(--bg-secondary, #141414);
    border: 1px solid var(--border-primary, #262626);
    border-radius: 8px;
    padding: 8px;
    color: var(--text-primary, #fafafa);
    cursor: pointer;
  }
}

@media (min-width: 769px) {
  .mobile-menu-btn { display: none; }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .stat-card .stat-value {
    font-size: 1.5rem;
  }
}

/* === GrapeJS Editor Overrides (dark theme) === */
.gjs-one-bg { background-color: #141414 !important; }
.gjs-two-color { color: #fafafa !important; }
.gjs-three-bg { background-color: #1e1e1e !important; }
.gjs-four-color, .gjs-four-color-h:hover { color: #3b82f6 !important; }
