/* ========================================
   RepoVault - Main Stylesheet
   ======================================== */

:root {
  --sidebar-width: 240px;
  --sidebar-bg: #1a1d23;
  --sidebar-text: #9ca3af;
  --sidebar-active: #6366f1;
  --sidebar-active-bg: rgba(99, 102, 241, 0.12);
  --topbar-height: 60px;
  --primary: #6366f1;
  --border-color: #e5e7eb;
  --bg-body: #f8f9fc;
  --card-shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}

/* ---- Base ---- */
body {
  background: var(--bg-body);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 0.875rem;
  color: #374151;
}

/* ---- Layout ---- */
.wrapper {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 1000;
  transition: transform .25s ease;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 18px;
  flex-shrink: 0;
}

.brand-name {
  font-size: 1rem;
  font-weight: 700;
  color: #f9fafb;
  line-height: 1.2;
  display: block;
}
.brand-sub {
  font-size: 0.7rem;
  color: #6b7280;
  display: block;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.sidebar-nav .nav {
  gap: 1px;
}

.nav-section-title {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #4b5563;
  padding: 16px 20px 4px;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  color: var(--sidebar-text);
  border-radius: 0;
  transition: background .15s, color .15s;
  font-size: 0.875rem;
}

.sidebar-nav .nav-link:hover {
  background: rgba(255,255,255,.06);
  color: #e5e7eb;
}

.sidebar-nav .nav-link.active {
  background: var(--sidebar-active-bg);
  color: #a5b4fc;
  border-right: 2px solid var(--sidebar-active);
}

.sidebar-nav .nav-link i {
  font-size: 16px;
  width: 18px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 12px 0 16px;
  border-top: 1px solid rgba(255,255,255,.06);
}

.logout-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  color: #6b7280;
  transition: color .15s;
  font-size: 0.875rem;
}
.logout-link:hover {
  color: #f87171;
}

/* ---- Main Content ---- */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ---- Topbar ---- */
.topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: center;
}

.sidebar-toggle {
  background: none;
  border: none;
  padding: 6px 8px;
  font-size: 20px;
  color: #6b7280;
  cursor: pointer;
  border-radius: 6px;
  line-height: 1;
  display: none;
}

.sidebar-toggle:hover {
  background: #f3f4f6;
  color: #374151;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #6b7280;
  font-size: 0.875rem;
}

.breadcrumb {
  font-size: 0.8125rem;
}

.breadcrumb-item + .breadcrumb-item::before {
  color: #d1d5db;
}

/* ---- Content Area ---- */
.content-area {
  flex: 1;
  padding: 24px;
}

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

.page-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #111827;
  margin: 0;
}

/* ---- Cards ---- */
.card {
  border: 1px solid #e5e7eb;
  box-shadow: var(--card-shadow);
  border-radius: 10px;
}

.card-header {
  background: #fff;
  border-bottom: 1px solid #f3f4f6;
  padding: 14px 18px;
  border-radius: 10px 10px 0 0 !important;
  font-size: 0.875rem;
}

.card-body {
  padding: 18px;
}

/* ---- Stat Cards ---- */
.stat-card {
  border-radius: 10px;
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1px solid #e5e7eb;
  background: #fff;
  box-shadow: var(--card-shadow);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  color: #111827;
}
.stat-label {
  font-size: 0.8rem;
  color: #6b7280;
  margin-top: 2px;
}

.stat-blue .stat-icon { background: #eff6ff; color: #3b82f6; }
.stat-green .stat-icon { background: #f0fdf4; color: #22c55e; }
.stat-purple .stat-icon { background: #f5f3ff; color: #8b5cf6; }
.stat-orange .stat-icon { background: #fff7ed; color: #f97316; }

/* ---- Tables ---- */
.table th {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #6b7280;
  border-bottom: 1px solid #f3f4f6;
  background: #fafafa;
}

.table td {
  font-size: 0.875rem;
  vertical-align: middle;
  border-color: #f3f4f6;
}

/* ---- API Key Items ---- */
.api-key-item {
  padding: 14px 18px;
  border-bottom: 1px solid #f3f4f6;
}

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

.api-key-item.api-key-blocked {
  background: #fff5f5;
}

.api-key-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.api-key-info {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.api-key-value {
  font-size: 0.8rem;
  cursor: pointer;
  padding: 2px 6px;
  background: #f3f4f6;
  border-radius: 4px;
  transition: background .15s;
}

.api-key-value:hover {
  background: #e0e7ff;
}

.api-key-actions {
  display: flex;
  gap: 4px;
}

.api-key-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 6px;
}

.api-key-stats span {
  font-size: 0.78rem;
  color: #6b7280;
  display: flex;
  align-items: center;
  gap: 4px;
}

.api-key-ips {
  margin-top: 8px;
}

.ip-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ip-item {
  display: flex;
  align-items: center;
  font-size: 0.8rem;
}

/* ---- Buttons ---- */
.btn-xs {
  padding: 2px 7px;
  font-size: 0.75rem;
  border-radius: 4px;
}

.form-control-xs {
  height: calc(1.5em + .5rem + 2px);
  padding: .25rem .5rem;
  font-size: .78rem;
  border-radius: .2rem;
}

/* ---- Version Items ---- */
.version-item {
  padding: 14px 18px;
  border-bottom: 1px solid #f3f4f6;
}
.version-item:last-child { border-bottom: none; }

.version-badge {
  display: inline-block;
  padding: 2px 10px;
  background: #eff6ff;
  color: #2563eb;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: 'SFMono-Regular', monospace;
}

.changelog-preview {
  padding: 8px 12px;
  background: #f9fafb;
  border-radius: 6px;
  border-left: 3px solid #e5e7eb;
}

.packages-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.pkg-badge {
  font-size: 0.78rem;
  padding: 3px 10px;
  background: #f0fdf4;
  color: #16a34a;
  border-radius: 99px;
  border: 1px solid #bbf7d0;
}

/* ---- Product Cards ---- */
.product-card {
  transition: box-shadow .2s;
}
.product-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
}

/* ---- Upload Zone ---- */
.upload-zone {
  border: 2px dashed #d1d5db;
  border-radius: 10px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--primary);
  background: #f5f3ff;
}
.upload-zone.has-file {
  border-color: #22c55e;
  background: #f0fdf4;
}

/* ---- Changelog ---- */
.changelog-version-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.changelog-version {
  font-size: 1.25rem;
  font-weight: 700;
  color: #111827;
  font-family: 'SFMono-Regular', monospace;
}

.changelog-date {
  font-size: 0.875rem;
}

.changelog-body {
  border-left: 4px solid var(--primary);
}

/* ---- Login Page ---- */
.login-page {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-wrapper {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
}

.login-logo {
  text-align: center;
  font-size: 48px;
  color: var(--primary);
  margin-bottom: 16px;
}

.login-title {
  text-align: center;
  margin-bottom: 28px;
}

.login-title h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 4px;
}

.login-title p {
  color: #6b7280;
  font-size: 0.875rem;
  margin: 0;
}

.btn-login {
  height: 44px;
  font-size: 0.9rem;
  font-weight: 500;
}

.login-footer {
  text-align: center;
  margin-top: 20px;
}

/* ---- Footer ---- */
.site-footer {
  background: #fff;
  border-top: 1px solid #e5e7eb;
  padding: 10px 24px;
  margin-top: auto;
}

.footer-inner {
  font-size: 0.78rem;
  color: #9ca3af;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.footer-left {
  color: #6b7280;
}

.footer-left a {
  color: #6b7280;
  text-decoration: none;
}
.footer-left a:hover {
  color: var(--primary);
}

.footer-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.footer-right a {
  color: #9ca3af;
  text-decoration: none;
}
.footer-right a:hover {
  color: var(--primary);
}

.footer-sep {
  color: #d1d5db;
}

.footer-version {
  font-family: 'SFMono-Regular', monospace;
  font-size: 0.75rem;
  color: #6366f1;
  background: #eef2ff;
  padding: 1px 7px;
  border-radius: 99px;
}

/* ---- Help Content ---- */
.help-content h4 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #111827;
}

.help-content h6 {
  font-weight: 600;
  color: #374151;
  margin-top: 16px;
}

.help-content pre {
  font-size: 0.8rem;
  overflow-x: auto;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.show {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .sidebar-toggle {
    display: block;
  }
  .content-area {
    padding: 16px;
  }
}

/* ---- Utilities ---- */
.text-xs { font-size: 0.75rem; }
code { background: #f3f4f6; padding: 1px 5px; border-radius: 3px; font-size: 0.8em; color: #6d28d9; }
pre code { background: none; color: inherit; padding: 0; }
