/* ==========================================================================
   Kisa Design System — MongoDB Atlas UI Language
   ========================================================================== */

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

/* ── CSS Variables ───────────────────────────────────────────────────── */

:root {
  /* Brand */
  --brand-green:        #00ED64;
  --brand-green-hover:  #00C853;
  --dark-green:         #001E2B;
  --mid-green:          #00684A;
  --nav-hover-bg:       rgba(255, 255, 255, 0.08);

  /* Neutral */
  --page-bg:            #FFFFFF;
  --content-bg:         #FAFAFA;
  --card-bg:            #FFFFFF;
  --card-border:        #E8EDEB;
  --divider:            #E8EDEB;

  /* Text */
  --text-primary:       #1C2D38;
  --text-secondary:     #5C6C75;
  --text-tertiary:      #889397;
  --text-inverse:       #FFFFFF;
  --sidebar-nav-text:   #C1C7C6;
  --link-blue:          #016BF8;

  /* Status */
  --success:            #00A35C;
  --warning:            #FFC010;
  --danger:             #DB3030;
  --info:               #016BF8;

  /* Layout */
  --sidebar-width:      216px;
  --topbar-height:      40px;
  --font-family:        "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --radius-sm:          4px;
  --radius-md:          6px;
  --radius-lg:          8px;
  --transition-fast:    150ms ease;
}

/* ── Reset & Base ─────────────────────────────────────────────────────── */

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

html, body {
  height: 100%;
  font-family: var(--font-family);
  font-size: 13px;
  font-weight: 400;
  line-height: 20px;
  color: var(--text-primary);
  background: var(--content-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--link-blue);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ── Typography ───────────────────────────────────────────────────────── */

h1, .h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
  line-height: 32px;
}

h2, .h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 24px;
}

h3, .h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 20px;
}

.label, .caption {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-secondary);
  line-height: 16px;
}

.micro {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-tertiary);
  line-height: 16px;
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 28px;
}

.stat-label {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.stat-sub {
  font-size: 11px;
  color: var(--text-tertiary);
}

/* ── Buttons ──────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-family);
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  line-height: 20px;
  white-space: nowrap;
  text-decoration: none;
}

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

.btn-primary {
  background: var(--brand-green);
  color: var(--dark-green);
}
.btn-primary:hover {
  background: var(--brand-green-hover);
}

.btn-secondary {
  background: var(--card-bg);
  color: var(--text-primary);
  border: 1px solid #C1C7C6;
}
.btn-secondary:hover {
  background: #F5F6F7;
}

.btn-danger {
  background: var(--danger);
  color: var(--text-inverse);
}
.btn-danger:hover {
  background: #C62828;
}

.btn-text {
  background: none;
  border: none;
  color: var(--link-blue);
  padding: 4px 8px;
  font-weight: 500;
}
.btn-text:hover {
  text-decoration: underline;
  background: none;
}

.btn-sm {
  padding: 4px 12px;
  font-size: 12px;
}

.btn-lg {
  padding: 10px 24px;
  font-size: 14px;
}

.btn-icon {
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.btn-icon:hover {
  background: #F5F6F7;
}

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

/* ── Forms ────────────────────────────────────────────────────────────── */

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.form-input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  font-size: 13px;
  font-family: var(--font-family);
  color: var(--text-primary);
  background: var(--card-bg);
  border: 1px solid #C1C7C6;
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus {
  outline: none;
  border-color: var(--link-blue);
  box-shadow: 0 0 0 2px rgba(1, 107, 248, 0.2);
}

.form-input::placeholder {
  color: var(--text-tertiary);
}

.form-input.error {
  border-color: var(--danger);
}
.form-input.error:focus {
  box-shadow: 0 0 0 2px rgba(219, 48, 48, 0.2);
}

.form-error {
  font-size: 11px;
  color: var(--danger);
  margin-top: 4px;
}

.form-select {
  width: 100%;
  height: 36px;
  padding: 0 32px 0 12px;
  font-size: 13px;
  font-family: var(--font-family);
  color: var(--text-primary);
  background: var(--card-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23889397' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid #C1C7C6;
  border-radius: var(--radius-md);
  appearance: none;
  cursor: pointer;
}
.form-select:focus {
  outline: none;
  border-color: var(--link-blue);
  box-shadow: 0 0 0 2px rgba(1, 107, 248, 0.2);
}

/* ── Cards ────────────────────────────────────────────────────────────── */

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
}

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

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ── Tabs ─────────────────────────────────────────────────────────────── */

.tabs {
  display: flex;
  border-bottom: 1px solid var(--divider);
  margin-bottom: 20px;
}

.tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  font-family: var(--font-family);
}

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

.tab.active {
  color: var(--text-primary);
  font-weight: 600;
  border-bottom-color: var(--mid-green);
}

/* ── Tags / Badges ────────────────────────────────────────────────────── */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  border: 1px dashed #C1C7C6;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-family);
  background: none;
}
.tag:hover {
  border-style: solid;
  color: var(--text-primary);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  font-family: var(--font-family);
}

.badge-success {
  background: rgba(0, 163, 92, 0.12);
  color: var(--success);
}

.badge-warning {
  background: rgba(255, 192, 16, 0.15);
  color: #8A6D00;
}

.badge-danger {
  background: rgba(219, 48, 48, 0.1);
  color: var(--danger);
}

.badge-info {
  background: rgba(1, 107, 248, 0.1);
  color: var(--info);
}

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

.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

thead th {
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  text-align: left;
  border-bottom: 1px solid var(--divider);
  white-space: nowrap;
}

tbody td {
  padding: 10px 12px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--divider);
}

tbody tr:hover {
  background: #F9FBFA;
}

/* ── Stat Tiles ───────────────────────────────────────────────────────── */

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

.stat-tile {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
}

.stat-trend {
  font-size: 12px;
  font-weight: 600;
  margin-top: 4px;
}

.stat-trend.up {
  color: var(--success);
}

.stat-trend.down {
  color: var(--danger);
}

/* ── Utilities ────────────────────────────────────────────────────────── */

.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-sm { gap: 8px; }
.gap-md { gap: 12px; }
.gap-base { gap: 16px; }
.gap-lg { gap: 20px; }
.gap-xl { gap: 24px; }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 12px; }
.mt-base { margin-top: 16px; }
.mt-xl { margin-top: 24px; }
.mb-sm { margin-bottom: 8px; }
.mb-base { margin-bottom: 16px; }
.mb-xl { margin-bottom: 24px; }
.ml-auto { margin-left: auto; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Two-column card grid ─────────────────────────────────────────────── */

.card-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ── Action row (sub-card) ────────────────────────────────────────────── */

.action-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.action-row:hover {
  background: #F9FBFA;
}

.action-row-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 237, 100, 0.12);
  border-radius: var(--radius-md);
  color: var(--mid-green);
  flex-shrink: 0;
}

.action-row-arrow {
  margin-left: auto;
  color: var(--text-tertiary);
  font-size: 16px;
}

/* ── Sidebar ──────────────────────────────────────────────────────────── */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--dark-green);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo svg {
  flex-shrink: 0;
}

.sidebar-logo-text {
  color: var(--text-inverse);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}

.sidebar-breadcrumb {
  padding: 0 16px 8px;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-tertiary);
}

.sidebar-nav-section {
  padding: 16px 16px 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--sidebar-nav-text);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--sidebar-nav-text);
  cursor: pointer;
  border-radius: 4px;
  transition: background var(--transition-fast), color var(--transition-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-family);
}

.sidebar-nav-item:hover {
  background: var(--nav-hover-bg);
}

.sidebar-nav-item.active {
  background: var(--mid-green);
  color: var(--text-inverse);
  font-weight: 600;
}

.sidebar-nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.7;
}
.sidebar-nav-item.active .sidebar-nav-icon {
  opacity: 1;
}

.sidebar-divider {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin: 8px 16px;
}

/* ── Topbar ───────────────────────────────────────────────────────────── */

.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: var(--dark-green);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  padding: 0 16px;
  z-index: 90;
}

.topbar-breadcrumb {
  font-size: 11px;
  color: var(--text-tertiary);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--mid-green);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: var(--font-family);
}

/* ── Main Content ─────────────────────────────────────────────────────── */

.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  padding: 24px 28px;
  min-height: calc(100vh - var(--topbar-height));
  background: var(--content-bg);
}

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

.page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

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

/* ── Login Page ───────────────────────────────────────────────────────── */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--content-bg);
}

.login-card {
  width: 400px;
  padding: 32px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.login-logo-text {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-tertiary);
  font-size: 12px;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--divider);
}

.login-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ── Toast / Notifications ────────────────────────────────────────────── */

.toast {
  position: fixed;
  top: 16px;
  right: 16px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-inverse);
  z-index: 1000;
  animation: slideIn 0.2s ease;
}

.toast-success { background: var(--success); }
.toast-error   { background: var(--danger); }
.toast-info    { background: var(--info); }

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

/* ── Modal ─────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

.modal {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 480px;
  max-width: 90vw;
}

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

.modal-title {
  font-size: 16px;
  font-weight: 700;
}

/* ── Empty state ──────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.empty-state-desc {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 16px;
}

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

@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  .card-grid-2 {
    grid-template-columns: 1fr;
  }
  .sidebar {
    width: 56px;
  }
  .sidebar-logo-text,
  .sidebar-nav-section,
  .sidebar-nav-item span,
  .sidebar-breadcrumb {
    display: none;
  }
  :root { --sidebar-width: 56px; }
  .login-card {
    width: 90vw;
  }
}
