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

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-family);
  font-size: var(--font-base);
  color: var(--color-text-primary);
  background: var(--color-bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── App Shell Layout ─────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--header-height) 1fr;
  grid-template-areas:
    "sidebar header"
    "sidebar main";
  min-height: 100vh;
  transition: grid-template-columns var(--transition);
}

.app-shell.sidebar-collapsed {
  grid-template-columns: var(--sidebar-collapsed) 1fr;
}

/* ── Main Content ─────────────────────────────────────── */
.main-content {
  grid-area: main;
  padding: var(--space-xl);
  overflow-y: auto;
  background: var(--color-bg);
}

/* ── Cards ────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-xl);
}

.card-title {
  font-size: var(--font-md);
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: var(--space-md);
}

/* ── Stat Cards ───────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.stat-card__label {
  font-size: var(--font-sm);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: .5px;
  font-weight: 500;
}

.stat-card__value {
  font-size: var(--font-2xl);
  font-weight: 700;
  color: var(--color-text-primary);
}

.stat-card__change {
  font-size: var(--font-sm);
  font-weight: 500;
}

.stat-card__change.positive { color: var(--color-success); }
.stat-card__change.negative { color: var(--color-danger); }

/* ── Buttons ──────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: var(--font-base);
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background var(--transition), box-shadow var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}
.btn-primary:hover { background: var(--color-primary-dark); }

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

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

/* ── Badges ───────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--font-sm);
  font-weight: 500;
}
.badge-success { background: #e6f4ea; color: var(--color-success); }
.badge-danger  { background: #fce8e6; color: var(--color-danger);  }
.badge-warning { background: #fef7e0; color: var(--color-warning); }
.badge-info    { background: var(--color-primary-light); color: var(--color-primary); }

/* ── Tables ───────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-base);
}

th {
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}

td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-primary);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--color-bg); }

/* ── Page header ──────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xl);
}

.page-title {
  font-size: var(--font-xl);
  font-weight: 700;
  color: var(--color-text-primary);
}

.page-subtitle {
  font-size: var(--font-base);
  color: var(--color-text-secondary);
  margin-top: 4px;
}

/* ── Empty state ──────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--color-text-secondary);
}

.empty-state__icon { font-size: 48px; margin-bottom: var(--space-md); }
.empty-state__title { font-size: var(--font-lg); font-weight: 600; margin-bottom: var(--space-sm); }

/* ── Loading spinner ──────────────────────────────────── */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast notifications ──────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--color-text-primary);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--font-base);
  animation: slide-in .25s ease;
  max-width: 360px;
}
.toast.success { background: var(--color-success); }
.toast.error   { background: var(--color-danger);  }
.toast.warning { background: var(--color-warning); }

@keyframes slide-in {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: 0 1fr;
  }
  .main-content { padding: var(--space-md); }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}
