﻿/* Breathe — Admin Panel Dark Theme */
:root {
  --bg: #0a0e1a;
  --surface: #111827;
  --surface-light: #1e293b;
  --accent: #00d4ff;
  --accent-glow: rgba(0, 212, 255, 0.15);
  --success: #00e676;
  --warning: #ffab00;
  --danger: #ff5252;
  --text: #e2e8f0;
  --text-secondary: #94a3b8;
  --radius: 14px;
  --radius-sm: 8px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* --- Login --- */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 0%, rgba(0, 212, 255, 0.08) 0%, transparent 60%);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--surface-light);
  border-radius: var(--radius);
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-card .logo {
  font-size: 48px;
  margin-bottom: 8px;
}

.login-card h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.login-card .subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 32px;
}

.login-card input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--surface-light);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  margin-bottom: 12px;
  outline: none;
  transition: border 0.2s;
}

.login-card input:focus {
  border-color: var(--accent);
}

.login-card button {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  margin-top: 8px;
}

.login-card button:hover {
  opacity: 0.85;
}

.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 12px;
}

/* --- Layout --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--surface-light);
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar .brand .logo {
  font-size: 28px;
}

.topbar .brand h1 {
  font-size: 18px;
  font-weight: 700;
}

.topbar .brand span {
  color: var(--text-secondary);
  font-size: 12px;
}

.topbar .actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar .actions .nav-link {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

.topbar .actions .nav-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.topbar .actions .nav-link.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-glow);
}

.topbar .actions .nav-sep {
  width: 1px;
  height: 20px;
  background: var(--surface-light);
  margin: 0 6px;
}

.topbar .time {
  color: var(--text-secondary);
  font-size: 13px;
  margin-right: 4px;
}

.btn {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--surface-light);
  background: transparent;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-accent {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.btn-accent:hover {
  opacity: 0.85;
}

.btn-danger {
  border-color: var(--danger);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: white;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 11px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 32px;
}

/* --- Protocol Cards --- */
.proto-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.proto-card {
  background: var(--surface);
  border: 1px solid var(--surface-light);
  border-radius: var(--radius);
  padding: 20px;
  transition: border 0.2s;
  position: relative;
  overflow: hidden;
}

.proto-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--card-color, var(--accent));
}

.proto-card:hover {
  border-color: var(--card-color, var(--accent));
}

.proto-card .header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.proto-card .header .info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.proto-card .header .icon {
  font-size: 24px;
}

.proto-card .header .name {
  font-weight: 600;
  font-size: 14px;
}

.proto-card .header .level {
  color: var(--text-secondary);
  font-size: 11px;
}

.badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-active {
  background: rgba(0, 230, 118, 0.15);
  color: var(--success);
}

.badge-inactive {
  background: rgba(255, 82, 82, 0.15);
  color: var(--danger);
}

.proto-card .details {
  display: flex;
  gap: 20px;
  color: var(--text-secondary);
  font-size: 12px;
}

.proto-card .details span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.proto-card .actions {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--surface-light);
}

/* --- System Info --- */
.sys-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.sys-card {
  background: var(--surface);
  border: 1px solid var(--surface-light);
  border-radius: var(--radius);
  padding: 20px;
}

.sys-card .label {
  color: var(--text-secondary);
  font-size: 12px;
  margin-bottom: 8px;
}

.sys-card .value {
  font-size: 28px;
  font-weight: 700;
}

.sys-card .sub {
  color: var(--text-secondary);
  font-size: 11px;
  margin-top: 4px;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--surface-light);
  border-radius: 3px;
  margin-top: 8px;
  overflow: hidden;
}

.progress-bar .fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.5s;
}

.progress-bar .fill.warning {
  background: var(--warning);
}

.progress-bar .fill.danger {
  background: var(--danger);
}

/* --- Section Headlines --- */
.section-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

/* --- Logs Modal --- */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--surface-light);
  border-radius: var(--radius);
  width: 90%;
  max-width: 700px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--surface-light);
}

.modal .modal-header h3 {
  font-size: 15px;
}

.modal .modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

.modal .modal-body pre {
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-all;
}

.modal .close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
}

.modal .close-btn:hover {
  color: var(--text);
}

/* --- Config Info --- */
.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.config-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.config-item .key {
  color: var(--text-secondary);
}

.config-item .val {
  font-weight: 500;
  font-family: monospace;
}

/* --- Data Tables --- */
.data-table-wrap {
  overflow-x: auto;
  margin-bottom: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--surface-light);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead {
  background: var(--surface);
}

.data-table th {
  text-align: left;
  padding: 12px 16px;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--surface-light);
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(30, 41, 59, 0.5);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background: rgba(0, 212, 255, 0.03);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.text-muted {
  color: var(--text-secondary);
  font-size: 12px;
}

/* --- Inline forms --- */
.inline-form {
  display: flex;
  gap: 6px;
  align-items: center;
}

.input-inline {
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--surface-light);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 12px;
  outline: none;
  transition: border 0.2s;
  font-family: inherit;
}

.input-inline:focus {
  border-color: var(--accent);
}

select.input-inline {
  appearance: none;
  cursor: pointer;
  padding-right: 24px;
  background-image: 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='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

/* --- Token codes --- */
.token-code {
  display: inline-block;
  padding: 4px 10px;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity 0.2s;
  letter-spacing: 0.05em;
}

.token-code:hover {
  opacity: 0.7;
}

.token-code.valid {
  background: rgba(0, 230, 118, 0.15);
  color: var(--success);
}

.token-code.used {
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-secondary);
}

.token-code.expired {
  background: rgba(255, 82, 82, 0.1);
  color: var(--danger);
}

/* --- Empty state --- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: var(--surface);
  border: 1px solid var(--surface-light);
  border-radius: var(--radius);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-state .text {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.empty-state .sub {
  font-size: 13px;
  color: var(--text-secondary);
}

/* --- Nav pills (admin pages) --- */
.nav-pills {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.nav-pills a {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-secondary);
  border: 1px solid var(--surface-light);
  transition: all 0.2s;
  text-decoration: none;
}

.nav-pills a:hover,
.nav-pills a.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-glow);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .container {
    padding: 16px;
  }

  .topbar {
    padding: 12px 16px;
  }

  .proto-grid {
    grid-template-columns: 1fr;
  }

  .sys-grid {
    grid-template-columns: 1fr 1fr;
  }

  .data-table {
    font-size: 12px;
  }

  .data-table th,
  .data-table td {
    padding: 8px 10px;
  }
}