@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --primary: #c9974a;
  --primary-dark: #b8863b;
  --primary-light: #e8dcc8;
  --primary-bg: #fef9e7;
  --secondary: #c9974a;
  --cta: #c9974a;
  --cta-hover: #b8863b;
  --text: #0f1b2d;
  --text-muted: #4B5563;
  --text-light: #c9974a;
  --bg: #FFFFFF;
  --bg-white: #FFFFFF;
  --bg-card: #FFFFFF;
  --border: #E5E7EB;
  --border-light: #F3F4F6;
  --sidebar-bg: #0f1b2d;
  --sidebar-text: #c9974a;
  --sidebar-active: #c9974a;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --transition: 200ms ease;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

code, pre, .font-mono {
  font-family: 'Fira Code', monospace;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--primary-dark);
}

img {
  max-width: 100%;
  height: auto;
}

/* ─── Buttons ─── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius);
  font-family: 'Fira Sans', sans-serif;
  font-weight: 500;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1.4;
}

.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
  color: white;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

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

.btn-secondary:hover {
  background: var(--primary-light);
  color: white;
  border-color: var(--primary-light);
}

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

.btn-cta:hover {
  background: var(--cta-hover);
  color: white;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-danger {
  background: #EF4444;
  color: white;
}

.btn-danger:hover {
  background: #DC2626;
  color: white;
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

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

.btn-secondary:hover {
  color: white;
}

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

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

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

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

/* ─── Page Title ─── */

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

/* ─── Cards ─── */

.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: box-shadow var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-body {
  padding: 1.5rem;
}

/* ─── Forms ─── */

.form-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: 'Fira Sans', sans-serif;
  font-size: 0.875rem;
  color: var(--text);
  background: var(--bg-white);
  transition: all var(--transition);
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.form-input::placeholder {
  color: #9CA3AF;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.375rem;
}

.form-error {
  font-size: 0.8125rem;
  color: #EF4444;
  margin-top: 0.25rem;
}

select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236B7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 2.5rem;
}

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

/* ─── Tables ─── */

.table-container {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-white);
}

table {
  width: 100%;
  border-collapse: collapse;
}

table th {
  background: var(--primary-bg);
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table td {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--text);
  border-bottom: 1px solid var(--border-light);
}

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

table tr:hover td {
  background: var(--primary-bg);
}

table tr.clickable {
  cursor: pointer;
}

/* ─── Badges ─── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.5;
}

.badge-green {
  background: #DCFCE7;
  color: #166534;
}

.badge-yellow {
  background: #FEF9C3;
  color: #854D0E;
}

.badge-red {
  background: #FEE2E2;
  color: #991B1B;
}

.badge-blue {
  background: #DBEAFE;
  color: #1E40AF;
}

.badge-purple {
  background: #EDE9FE;
  color: #5B21B6;
}

.badge-gray {
  background: #F3F4F6;
  color: #374151;
}

/* ─── Flash Messages ─── */

.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.flash-success {
  background: #DCFCE7;
  color: #166534;
  border: 1px solid #86EFAC;
}

.flash-error {
  background: #FEE2E2;
  color: #991B1B;
  border: 1px solid #FCA5A5;
}

.flash-info {
  background: #DBEAFE;
  color: #1E40AF;
  border: 1px solid #93C5FD;
}

/* ─── Pagination ─── */

.pagination {
  display: flex;
  justify-content: center;
  gap: 0.375rem;
  margin-top: 1.5rem;
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 0.5rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--bg-white);
  transition: all var(--transition);
}

.pagination a:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.pagination .active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ─── Infinite Scroll Loading Spinner ─── */

.loading-spinner {
    width: 2.5rem;
    height: 2.5rem;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

#scroll-sentinel .loading-spinner {
    display: none;
}

#scroll-sentinel.loading .loading-spinner {
    display: inline-block;
}

/* ─── Utility ─── */

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

.text-sm {
  font-size: 0.875rem;
}

.text-xs {
  font-size: 0.75rem;
}

.font-semibold {
  font-weight: 600;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

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

.justify-between {
  justify-content: space-between;
}

.justify-center {
  justify-content: center;
}

.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }

/* ─── Animations ─── */

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

.animate-fade-in {
  animation: fadeIn 300ms ease forwards;
}

@keyframes slideIn {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

/* ─── Responsive Tables ─── */

@media (max-width: 768px) {
  .table-container {
    border-radius: var(--radius);
  }

  table {
    font-size: 0.8125rem;
  }

  table th,
  table td {
    padding: 0.5rem 0.75rem;
  }

  .card-body {
    padding: 1rem;
  }
}
