/* KEHE Price Inventory Sync — admin UI */

:root {
  --navy: #0f2744;
  --navy-light: #1a3a5c;
  --navy-hover: #243f63;
  --accent: #2d7dd2;
  --accent-hover: #256bb5;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --sidebar-width: 240px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(15, 39, 68, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--navy);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.65rem;
}

.sidebar-logo {
  display: block;
  max-width: 100%;
  width: auto;
  max-height: 56px;
  height: auto;
  object-fit: contain;
}

.sidebar-app-name {
  font-weight: 600;
  font-size: 0.85rem;
  line-height: 1.35;
  color: #f1f5f9;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  max-width: 100%;
}

.sidebar nav {
  padding: 0.75rem 0;
  flex: 1;
}

.sidebar nav a {
  display: block;
  padding: 0.55rem 1.25rem;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 0.9rem;
  border-left: 3px solid transparent;
}

.sidebar nav a:hover,
.sidebar nav a.active {
  background: var(--navy-hover);
  color: #fff;
  text-decoration: none;
  border-left-color: var(--accent);
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.8rem;
  color: #94a3b8;
}

.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 1.5rem 2rem;
  max-width: 1200px;
}

.page-header {
  margin-bottom: 1.5rem;
}

.page-header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
  font-weight: 600;
}

.page-header p {
  margin: 0;
  color: var(--text-muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.card h2 {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  background: #f8fafc;
}

tr:hover td {
  background: #f8fafc;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success { background: #d1fae5; color: var(--success); }
.badge-warning { background: #fef3c7; color: var(--warning); }
.badge-danger { background: #fee2e2; color: var(--danger); }
.badge-muted { background: #f1f5f9; color: var(--text-muted); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  background: var(--accent);
  color: #fff;
}

.btn:hover {
  background: var(--accent-hover);
  text-decoration: none;
  color: #fff;
}

.btn-secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: #f8fafc;
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
}

.btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 500;
  font-size: 0.875rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.875rem;
  font-family: inherit;
}

.form-group textarea {
  min-height: 100px;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.alert-info { background: #dbeafe; color: #1e40af; }
.alert-success { background: #d1fae5; color: #065f46; }
.alert-error { background: #fee2e2; color: #991b1b; }

.log-viewer {
  background: #0f172a;
  color: #e2e8f0;
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 0.8rem;
  padding: 1rem;
  border-radius: var(--radius);
  max-height: 480px;
  overflow-y: auto;
  line-height: 1.6;
}

/* Logs page — fill remaining viewport height */
.main-logs {
  max-width: none;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  padding: 1rem 1.25rem;
}

.logs-page {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 0.75rem;
}

.logs-page-header {
  flex-shrink: 0;
}

.logs-page-header .page-header {
  margin-bottom: 0.75rem;
}

.logs-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.25rem;
}

.logs-auto-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 500;
}

.logs-refresh-status {
  margin: 0;
}

.log-viewer-full {
  flex: 1;
  min-height: 0;
  max-height: none;
  height: auto;
  border: 1px solid #1e293b;
}

.log-line { margin: 0; }
.log-line.level-ERROR { color: #f87171; }
.log-line.level-WARNING { color: #fbbf24; }
.log-line.level-SUCCESS { color: #34d399; }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, #1e4976 100%);
}

.login-card {
  background: var(--surface);
  padding: 2rem;
  border-radius: 12px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.login-card .brand {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-card .brand img {
  max-width: 100%;
  max-height: 64px;
  height: auto;
  width: auto;
  object-fit: contain;
  margin-bottom: 0.75rem;
}

.login-card h1 {
  margin: 0;
  font-size: 1.25rem;
}

.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--navy);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

@media (max-width: 768px) {
  .sidebar {
    position: relative;
    width: 100%;
  }
  .main {
    margin-left: 0;
  }
  .layout {
    flex-direction: column;
  }
}
