/* AdFlow - Minimal CSS */
:root {
  --text: #1a1a1a;
  --text-muted: #666;
  --bg: #fff;
  --bg-subtle: #f8f9fa;
  --border: #e1e4e8;
  --primary: #0066cc;
  --primary-hover: #0052a3;
  --success: #28a745;
  --warning: #ffc107;
  --danger: #dc3545;
  --radius: 6px;

  /* Aliases for error page */
  --color-primary: var(--primary);
  --color-text: var(--text);
  --color-text-secondary: var(--text-muted);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

/* Layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

/* Login Container */
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  padding: 2rem;
}

.login-container h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.login-container .subtitle {
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.login-container .hint {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 1rem;
}

/* Navigation */
.navbar {
  display: flex;
  align-items: center;
  padding: 1rem 2rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.navbar .logo {
  font-weight: 700;
  font-size: 1.25rem;
  text-decoration: none;
  color: var(--text);
  margin-right: 2rem;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  flex: 1;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-muted);
  transition: color 0.15s;
}

.nav-links a:hover {
  color: var(--text);
}

.logout-form {
  margin-left: auto;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #c82333;
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #218838;
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.stat-card {
  background: var(--bg-subtle);
  padding: 1.5rem;
  border-radius: var(--radius);
}

.stat-card h3 {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
}

/* Pending Grid */
.pending-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.pending-card {
  background: var(--bg);
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.pending-card h3 {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.pending-count {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.pending-card a {
  color: var(--primary);
  text-decoration: none;
  font-size: 0.875rem;
}

.pending-card a:hover {
  text-decoration: underline;
}

/* Section */
.section {
  margin: 2rem 0;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.section h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

/* Tables */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.table th,
.table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table th {
  background: var(--bg-subtle);
  font-weight: 500;
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.table tr:last-child td {
  border-bottom: none;
}

.table tr:hover {
  background: var(--bg-subtle);
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem !important;
}

/* Status Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.badge-draft {
  background: var(--bg-subtle);
  color: var(--text-muted);
}

.badge-submitted {
  background: #fff3cd;
  color: #856404;
}

.badge-approved {
  background: #d4edda;
  color: #155724;
}

.badge-rejected {
  background: #f8d7da;
  color: #721c24;
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.625rem 0.75rem;
  font-size: 0.9375rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  transition: border-color 0.15s;
}

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

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

.form-error {
  color: var(--danger);
  font-size: 0.8125rem;
  margin-top: 0.25rem;
}

.form-hint {
  color: var(--text-muted);
  font-size: 0.8125rem;
  margin-top: 0.25rem;
}

/* Cards */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

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

.card-subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Alerts */
.alert {
  padding: 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.alert-success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.alert-error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.alert-warning {
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffeeba;
}

/* Utilities */
.text-muted {
  color: var(--text-muted);
}

.text-right {
  text-align: right;
}

.text-center {
  text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* HTMX loading indicator */
.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator {
  display: inline-block;
}

.htmx-request.htmx-indicator {
  display: inline-block;
}

/* Responsive - Tablet */
@media (max-width: 1024px) {
  .container {
    padding: 1.5rem;
  }

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

/* Responsive - Mobile */
@media (max-width: 768px) {
  .navbar {
    flex-wrap: wrap;
    padding: 1rem;
    gap: 0.5rem;
  }

  .nav-links {
    order: 3;
    width: 100%;
    margin-top: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    gap: 1rem;
  }

  .logout-form {
    order: 2;
  }

  .container {
    padding: 1rem;
  }

  .stats-grid,
  .pending-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .stat-card,
  .pending-card {
    padding: 1rem;
  }

  .stat-value {
    font-size: 1.5rem;
  }

  .section-header {
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-start;
  }

  /* Responsive table */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table {
    font-size: 0.8125rem;
    min-width: 600px;
  }

  .table th,
  .table td {
    padding: 0.5rem 0.625rem;
    white-space: nowrap;
  }

  /* Forms on mobile */
  .form-input,
  .form-select,
  .form-textarea {
    font-size: 16px; /* Prevents iOS zoom on focus */
  }

  .btn {
    padding: 0.75rem 1rem;
    width: 100%;
    justify-content: center;
  }

  .btn-sm {
    width: auto;
    padding: 0.375rem 0.75rem;
  }

  .card {
    padding: 1rem;
  }

  .card-header {
    flex-direction: column;
    gap: 0.5rem;
  }

  /* Login page mobile */
  .login-container h1 {
    font-size: 2rem;
  }

  /* Error page mobile */
  .error-container {
    padding: 1.5rem;
  }

  .error-code {
    font-size: 4rem;
  }

  .error-title {
    font-size: 1.25rem;
  }

  .error-actions {
    flex-direction: column;
    width: 100%;
  }

  .error-actions .btn {
    width: 100%;
  }
}

/* Small mobile */
@media (max-width: 480px) {
  .navbar .logo {
    font-size: 1.125rem;
    margin-right: 0;
  }

  .nav-links {
    gap: 0.75rem;
  }

  .nav-links a {
    font-size: 0.875rem;
  }

  .badge {
    font-size: 0.6875rem;
    padding: 0.1875rem 0.375rem;
  }
}

/* Audit Log Page */
.audit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.audit-header h1 {
  font-size: 1.25rem;
  font-weight: 600;
}

.audit-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  padding: 1rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.audit-filters .filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.audit-filters label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.audit-filters select,
.audit-filters input[type="date"] {
  padding: 0.5rem 0.625rem;
  font-size: 0.8125rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  min-width: 120px;
}

.audit-filters select:focus,
.audit-filters input[type="date"]:focus {
  outline: none;
  border-color: var(--primary);
}

.audit-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.audit-filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.5rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.75rem;
}

.audit-filter-tag a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
}

.audit-filter-tag a:hover {
  color: var(--danger);
}

/* Audit table specific */
.audit-table {
  font-size: 0.8125rem;
}

.audit-table th {
  font-size: 0.6875rem;
  padding: 0.625rem 1rem;
}

.audit-table td {
  padding: 0.625rem 1rem;
  vertical-align: middle;
}

.audit-table .col-time {
  width: 140px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.audit-table .col-actor {
  width: 200px;
}

.audit-table .col-action {
  width: 100px;
}

.audit-table .col-entity {
  width: 180px;
}

.audit-table .actor-email {
  font-weight: 500;
  color: var(--text);
}

.audit-table .actor-type {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.audit-table .entity-name {
  font-weight: 500;
  color: var(--text);
}

.audit-table .entity-type {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.audit-table .summary {
  color: var(--text-muted);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Action badges - only these need color */
.badge-action {
  display: inline-block;
  padding: 0.1875rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 500;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.badge-action-created {
  background: #e3f2fd;
  color: #1565c0;
}

.badge-action-submitted {
  background: #fff8e1;
  color: #f57c00;
}

.badge-action-approved {
  background: #e8f5e9;
  color: #2e7d32;
}

.badge-action-rejected {
  background: #ffebee;
  color: #c62828;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

.pagination-info {
  font-size: 0.8125rem;
  color: var(--text-muted);
  padding: 0 0.75rem;
}

.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.15s;
}

.pagination-btn:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

.pagination-btn svg {
  width: 16px;
  height: 16px;
}

/* Activity Feed */
.activity-feed {
  margin-top: 2rem;
}

.activity-feed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.activity-feed-header h3 {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.activity-feed-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.activity-list {
  list-style: none;
}

.activity-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

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

.activity-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.activity-icon svg {
  width: 12px;
  height: 12px;
  color: white;
}

.activity-icon-created { background: #1565c0; }
.activity-icon-submitted { background: #f57c00; }
.activity-icon-approved { background: #2e7d32; }
.activity-icon-rejected { background: #c62828; }

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

.activity-text {
  font-size: 0.8125rem;
  color: var(--text);
}

.activity-text strong {
  font-weight: 500;
}

.activity-summary {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.activity-time {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  color: var(--text-muted);
}

.activity-empty {
  font-size: 0.8125rem;
  color: var(--text-muted);
  padding: 1rem 0;
}

.activity-view-all {
  margin-top: 1rem;
}

.activity-view-all a {
  font-size: 0.8125rem;
  color: var(--primary);
  text-decoration: none;
}

.activity-view-all a:hover {
  text-decoration: underline;
}
