:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --bg-body: #f3f4f6;
  --bg-surface: #ffffff;
  --bg-sidebar: #1f2937;
  --text-main: #111827;
  --text-muted: #6b7280;
  --text-light: #f9fafb;
  --border: #e5e7eb;
  --danger: #ef4444;
  --success: #10b981;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --radius: 0.5rem;
  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-main);
  margin: 0;
  display: flex;
  min-height: 100vh;
}

/* Login Page */
body.login-page {
  align-items: center;
  justify-content: center;
  background: var(--bg-sidebar);
}

.login-card {
  background: var(--bg-surface);
  padding: 2.5rem;
  border-radius: var(--radius);
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}
.login-header { text-align: center; margin-bottom: 2rem; }
.login-header h1 { margin: 0; font-size: 1.5rem; color: var(--text-main); }
.login-header p { color: var(--text-muted); margin-top: 0.5rem; }

/* Dashboard Layout */
.app-shell {
  display: flex;
  width: 100%;
}

.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  color: var(--text-light);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 1.5rem;
  font-weight: 700;
  font-size: 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  color: #d1d5db;
  text-decoration: none;
  border-radius: var(--radius);
  transition: background 0.2s, color 0.2s;
}

.nav-link:hover, .nav-link.active {
  background: rgba(255,255,255,0.1);
  color: white;
}

.nav-link svg {
  width: 20px;
  height: 20px;
  margin-right: 0.75rem;
  opacity: 0.8;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.user-avatar {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: white;
}

.user-info {
  font-size: 0.875rem;
}

.logout-btn {
  width: 100%;
  background: none;
  border: 1px solid rgba(255,255,255,0.2);
  color: #d1d5db;
  padding: 0.5rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}
.logout-btn:hover { background: rgba(255,255,255,0.1); color: white; }

.main-content {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
}

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

.page-title { margin: 0; font-size: 1.875rem; font-weight: 700; color: var(--text-main); }
.page-actions { display: flex; gap: 1rem; }

/* Cards & Content */
.card {
  background: var(--bg-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card-header h3 { margin: 0; font-size: 1.1rem; color: var(--text-main); }

.card-body {
  padding: 1.5rem;
}

/* Grid for Repos */
.repo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.repo-card {
  background: var(--bg-surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.repo-card-header {
  margin-bottom: 1rem;
}
.repo-title { font-size: 1.25rem; font-weight: 600; color: var(--text-main); margin-bottom: 0.25rem; }
.repo-path { font-size: 0.875rem; color: var(--text-muted); font-family: monospace; background: #f3f4f6; padding: 0.125rem 0.375rem; border-radius: 4px; }

.repo-details {
  flex: 1;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}
.repo-detail-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
.repo-detail-row svg { width: 16px; height: 16px; opacity: 0.7; }

.repo-actions {
  display: flex;
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* Forms */
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; margin-bottom: 0.5rem; font-weight: 500; color: var(--text-main); }
.form-control {
  width: 100%;
  padding: 0.625rem;
  border: 1px solid #d1d5db;
  border-radius: var(--radius);
  font-size: 1rem;
  transition: border-color 0.2s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1); }
textarea.form-control { min-height: 120px; resize: vertical; }
.help-text { font-size: 0.875rem; color: var(--text-muted); margin-top: 0.375rem; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius);
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all 0.2s;
  font-size: 0.95rem;
  gap: 0.5rem;
}

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

.btn-secondary { background: white; border-color: #d1d5db; color: var(--text-main); }
.btn-secondary:hover { background: #f9fafb; border-color: #9ca3af; }

.btn-danger { background: #fee2e2; color: #b91c1c; border-color: transparent; }
.btn-danger:hover { background: #fecaca; }

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.875rem; }
.btn-block { width: 100%; }

/* Tables */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 0.75rem 1rem; background: #f9fafb; font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); border-bottom: 1px solid var(--border); }
td { padding: 1rem; border-bottom: 1px solid var(--border); color: var(--text-main); }
tr:last-child td { border-bottom: none; }

/* Alerts */
.alert { padding: 1rem; border-radius: var(--radius); margin-bottom: 1.5rem; display: flex; align-items: flex-start; gap: 0.75rem; }
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* Utility */
.badge { display: inline-block; padding: 0.25rem 0.5rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 600; }
.badge-gray { background: #f3f4f6; color: var(--text-muted); }
.badge-admin { background: #e0e7ff; color: #4338ca; }

/* Update Overlay */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay-content {
  background: var(--bg-surface);
  padding: 2.5rem;
  border-radius: var(--radius);
  width: 90%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.spinner-container {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e5e7eb;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.progress-container {
  margin-top: 1.5rem;
  background: #e5e7eb;
  border-radius: 9999px;
  height: 0.5rem;
  overflow: hidden;
  width: 100%;
}

.progress-bar {
  background: var(--primary);
  height: 100%;
  width: 0%;
  transition: width 0.3s ease;
}

@media (max-width: 768px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; }
  .sidebar-nav { flex-direction: row; overflow-x: auto; }
  .nav-link span { display: none; }
  .nav-link svg { margin: 0; }
  .sidebar-footer { display: none; }
  .main-content { padding: 1rem; }
}
