/* ABOUTME: Main stylesheet for Deploy admin dashboard */
/* ABOUTME: Utilitarian design with JetBrains Mono, light/dark themes, and hot pink accent */

/* ============================================
   CSS Custom Properties (Theme System)
   ============================================ */

:root {
  /* Font */
  --font-mono: "JetBrains Mono", monospace;

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Font sizes */
  --text-xs: 11px;
  --text-sm: 12px;
  --text-base: 14px;
  --text-lg: 16px;
  --text-xl: 20px;
  --text-2xl: 24px;

  /* Signature accent */
  --accent: #e91e8c;
  --accent-hover: #d11a7a;

  /* Status colors */
  --status-running: #22c55e;
  --status-stopped: #ef4444;
  --status-building: #f59e0b;
  --status-error: #ef4444;
}

/* Light theme (default) */
:root,
[data-theme="light"] {
  --bg: #ffffff;
  --bg-surface: #f8f8f8;
  --bg-hover: #f0f0f0;
  --border: #e0e0e0;
  --border-hover: #c0c0c0;
  --text: #1a1a1a;
  --text-muted: #6b6b6b;
  --text-faint: #999999;
}

/* Dark theme */
[data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-surface: #141414;
  --bg-hover: #1a1a1a;
  --border: #2a2a2a;
  --border-hover: #3a3a3a;
  --text: #f0f0f0;
  --text-muted: #888888;
  --text-faint: #555555;
}

/* ============================================
   Reset & Base
   ============================================ */

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

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

/* ============================================
   Layout
   ============================================ */

.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.header-brand {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: var(--text);
}

.header-brand-name {
  font-weight: 700;
  font-size: var(--text-lg);
  letter-spacing: -0.02em;
}

.header-brand-domain {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.header-nav {
  display: flex;
  gap: var(--space-1);
}

.nav-link {
  padding: var(--space-2) var(--space-3);
  color: var(--text-muted);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 500;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.nav-link:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.nav-link.active {
  color: var(--accent);
  border-color: var(--border);
  background: var(--bg-surface);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.app-main,
.main-content {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: var(--space-6) var(--space-5);
}

/* ============================================
   Theme Toggle
   ============================================ */

.theme-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1);
  border: 1px solid var(--border);
  background: var(--bg-surface);
}

.theme-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--text-sm);
  transition: all 0.15s ease;
}

.theme-btn:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.theme-btn.active {
  color: var(--accent);
  background: var(--bg);
}

/* ============================================
   Page Header
   ============================================ */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  gap: var(--space-4);
}

.page-title {
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ============================================
   Search Input
   ============================================ */

.search-input {
  width: 250px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

.search-input::placeholder {
  color: var(--text-faint);
}

.search-input:focus {
  outline: none;
  border-color: var(--border-hover);
}

/* ============================================
   Buttons
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}

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

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

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

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

.btn-sm {
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
}

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

.btn-danger {
  color: var(--status-error);
  border-color: var(--status-error);
}

.btn-danger:hover {
  background: var(--status-error);
  color: #ffffff;
}

/* ============================================
   Sites List
   ============================================ */

.sites-list {
  border: 1px solid var(--border);
}

.site-row {
  display: flex;
  align-items: center;
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
  gap: var(--space-4);
  transition: background 0.15s ease;
}

.site-row:last-child {
  border-bottom: none;
}

.site-row:hover {
  background: var(--bg-surface);
}

.site-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.site-status.running {
  background: var(--status-running);
  box-shadow: 0 0 8px var(--status-running);
}

.site-status.stopped {
  background: var(--status-stopped);
}

.site-status.building {
  background: var(--status-building);
  animation: pulse 1.5s ease-in-out infinite;
}

.site-status.error {
  background: var(--status-error);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.site-info {
  flex: 1;
  min-width: 0;
}

.site-name-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.site-name {
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  transition: color 0.15s ease;
}

.site-name:hover {
  color: var(--accent);
}

.site-badge {
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid var(--status-running);
  color: var(--status-running);
}

.site-url {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.site-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ============================================
   Dropdown
   ============================================ */

.dropdown {
  position: relative;
}

.dropdown-trigger {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--text-base);
  transition: all 0.15s ease;
}

.dropdown-trigger:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 180px;
  background: var(--bg);
  border: 1px solid var(--border);
  z-index: 50;
  display: none;
}

.dropdown.open .dropdown-menu {
  display: block;
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: var(--space-3);
  border: none;
  background: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
}

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

.dropdown-item.danger {
  color: var(--status-error);
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-2) 0;
}

/* ============================================
   Site Detail Page
   ============================================ */

.site-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-5);
}

.site-detail-info {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
}

.site-detail-title {
  font-size: var(--text-xl);
  font-weight: 600;
}

.site-detail-meta {
  margin-top: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.site-detail-meta a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: var(--text-sm);
}

.site-detail-meta a:hover {
  color: var(--accent);
}

.site-detail-actions {
  display: flex;
  gap: var(--space-2);
}

/* ============================================
   Tabs
   ============================================ */

.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-5);
}

.tab {
  padding: var(--space-3) var(--space-4);
  border: none;
  background: none;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s ease;
}

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

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ============================================
   Logs
   ============================================ */

.logs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.logs-title {
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.logs-container {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: var(--space-4);
  max-height: 500px;
  overflow-y: auto;
  font-size: var(--text-sm);
}

.log-line {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-1) 0;
  border-bottom: 1px solid var(--border);
}

.log-line:last-child {
  border-bottom: none;
}

.log-time {
  color: var(--text-faint);
  flex-shrink: 0;
  font-size: var(--text-xs);
}

.log-content {
  flex: 1;
  word-break: break-word;
}

.log-line.error .log-content {
  color: var(--status-error);
}

.log-line.success .log-content {
  color: var(--status-running);
}

/* ============================================
   Forms
   ============================================ */

.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input {
  width: 100%;
  padding: var(--space-3);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--text-base);
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
}

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

.form-radio-group {
  display: flex;
  gap: var(--space-4);
}

.form-radio {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}

.form-radio input {
  accent-color: var(--accent);
}

.form-checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}

.form-checkbox input {
  accent-color: var(--accent);
}

/* ============================================
   Modal
   ============================================ */

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

.modal {
  background: var(--bg);
  border: 1px solid var(--border);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

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

.modal-title {
  font-size: var(--text-lg);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--text-lg);
}

.modal-close:hover {
  color: var(--text);
}

.modal-body {
  padding: var(--space-5);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4);
  border-top: 1px solid var(--border);
}

/* ============================================
   Environment Variables
   ============================================ */

.env-table {
  width: 100%;
  border: 1px solid var(--border);
}

.env-row {
  display: grid;
  grid-template-columns: 1fr 2fr auto;
  border-bottom: 1px solid var(--border);
}

.env-row:last-child {
  border-bottom: none;
}

.env-cell {
  padding: var(--space-3);
  font-size: var(--text-sm);
}

.env-key {
  font-weight: 600;
  background: var(--bg-surface);
}

.env-value {
  font-family: var(--font-mono);
  color: var(--text-muted);
}

/* ============================================
   Settings Section
   ============================================ */

.settings-section {
  padding: var(--space-5);
  border: 1px solid var(--border);
  margin-bottom: var(--space-4);
}

.settings-section-title {
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-4);
}

.settings-section.danger {
  border-color: var(--status-error);
}

.settings-section.danger .settings-section-title {
  color: var(--status-error);
}

/* ============================================
   Empty State
   ============================================ */

.empty-state {
  text-align: center;
  padding: var(--space-8);
  color: var(--text-muted);
}

.empty-state-title {
  font-size: var(--text-lg);
  margin-bottom: var(--space-2);
}

/* ============================================
   Back Link
   ============================================ */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-muted);
  text-decoration: none;
  font-size: var(--text-sm);
  margin-bottom: var(--space-5);
}

.back-link:hover {
  color: var(--text);
}

/* ============================================
   Utilities
   ============================================ */

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

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

.text-error {
  color: var(--status-error);
}

.text-success {
  color: var(--status-running);
}

.mt-4 {
  margin-top: var(--space-4);
}

.mb-4 {
  margin-bottom: var(--space-4);
}

.flex {
  display: flex;
}

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

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

.gap-2 {
  gap: var(--space-2);
}

.gap-3 {
  gap: var(--space-3);
}

.gap-4 {
  gap: var(--space-4);
}

/* ============================================
   Badges
   ============================================ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid var(--border);
  background: var(--bg-surface);
}

.badge-success {
  border-color: var(--status-running);
  color: var(--status-running);
}

.badge-error {
  border-color: var(--status-error);
  color: var(--status-error);
}

.badge-warning {
  border-color: var(--status-building);
  color: var(--status-building);
}

/* ============================================
   Deployments
   ============================================ */

.deployments-section {
  margin-bottom: var(--space-6);
}

.deployments-section.deployments-active {
  padding: var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--status-building);
}

.section-title {
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}

.deployments-list {
  border: 1px solid var(--border);
}

.deployments-active .deployments-list {
  border: none;
}

.deployment-row {
  display: flex;
  align-items: flex-start;
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
  gap: var(--space-4);
  transition: background 0.15s ease;
}

.deployment-row:last-child {
  border-bottom: none;
}

.deployment-row:hover {
  background: var(--bg-surface);
}

.deployment-row.deployment-active {
  background: transparent;
}

.deployment-row.deployment-active:hover {
  background: var(--bg-hover);
}

.deployment-info {
  flex: 1;
  min-width: 0;
}

.deployment-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.deployment-site-name {
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  transition: color 0.15s ease;
}

.deployment-site-name:hover {
  color: var(--accent);
}

.deployment-meta {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.deployment-time {
  color: var(--text-faint);
}

.deployment-duration {
  font-weight: 500;
}

.deployment-commit {
  font-family: var(--font-mono);
  padding: var(--space-1) var(--space-2);
  background: var(--bg-hover);
  font-size: var(--text-xs);
}

.deployment-error {
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: rgba(239, 68, 68, 0.1);
  border-left: 2px solid var(--status-error);
  color: var(--status-error);
  font-size: var(--text-sm);
}

.deployment-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--status-building);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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