/* Almaviva User Web — mirrors the PyQt6 stylesheet (styles.py). */

:root {
  --text: #eae8fb;
  --muted: #9b96c8;
  --primary: #8b5cf6;
  --primary-hover: #a78bfa;
  --primary-deep: #7c3aed;
  --primary-pressed: #6d28d9;
  --active-green: #34d399;
  --inactive-red: #f87171;
  --pending-blue: #7dd3fc;
  --table-bg: #0c0a1d;
  --surface-bg: #14122b;
  --surface-border: #35325c;
  --panel-bg: rgba(17, 14, 36, 0.92);
  --panel-border: #2c2852;
  --selection-bg: #2b2450;
  --row-active: #102b1f;
  --row-inactive: #2b1524;
  --row-pending: #161a38;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

body {
  background: linear-gradient(135deg, #0a0718 0%, #0e0a20 45%, #0b0722 75%, #060412 100%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 12px;
}

.hidden { display: none !important; }
.muted-text { color: var(--muted); }

/* ============================ Screens ================================== */

.screen { min-height: 100vh; }

/* ============================ Login ==================================== */

.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: linear-gradient(180deg, rgba(28, 24, 64, 0.95), rgba(15, 13, 38, 0.95));
  border: 1px solid #37315f;
  border-radius: 20px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 24px 64px rgba(2, 0, 14, 0.55);
}

.auth-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto;
  border-radius: 36px;
  background: rgba(139, 92, 246, 0.14);
  border: 1px solid rgba(139, 92, 246, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-logo img { width: 42px; height: 42px; }

.brand-label {
  text-align: center;
  color: var(--primary);
  font-weight: 800;
  margin-top: 6px;
}

.app-title {
  margin: 0;
  text-align: center;
  color: #f8f7ff;
  font-size: 24px;
  font-weight: 800;
}

.subtitle {
  margin: 0;
  text-align: center;
  color: var(--muted);
}

.error-label {
  color: #fda4af;
  font-weight: 600;
  min-height: 16px;
  text-align: center;
}

/* ============================ Inputs =================================== */

.input, select.input {
  background-color: var(--surface-bg);
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  color: var(--text);
  padding: 9px 12px;
  min-height: 42px;
  font-size: 12px;
  outline: none;
  width: 100%;
}

.input:hover { border-color: #4b447f; }
.input:focus { border-color: var(--primary); background-color: #18143a; }
.input:disabled { background-color: #100e24; color: #6d6798; }

.input::placeholder { color: #6d6798; }

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

.btn {
  background-color: #1e1b3a;
  border: 1px solid #363259;
  border-radius: 10px;
  color: var(--text);
  font-weight: 700;
  padding: 8px 13px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover { background-color: #272347; border-color: #44407a; }
.btn:active { background-color: #171430; }
.btn:disabled { background-color: #171530; color: #6d6798; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(180deg, var(--primary), var(--primary-deep));
  border-color: var(--primary-pressed);
  color: #fff;
}

.btn-primary:hover { background: linear-gradient(180deg, var(--primary-hover), var(--primary)); }
.btn-primary:active { background-color: var(--primary-pressed); }

.btn-danger {
  background: linear-gradient(180deg, #dc2626, #b91c1c);
  border-color: #a21c1c;
  color: #fff;
}

.btn-danger:hover { background-color: #e04545; }

.btn-block { width: 100%; min-height: 42px; }

/* ============================ Dashboard ================================ */

.dashboard-screen {
  display: flex;
  gap: 12px;
  padding: 10px;
  align-items: stretch;
}

.panel {
  background-color: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
}

.sidebar {
  width: 196px;
  min-width: 176px;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.brand-title {
  text-align: center;
  color: #f8f7ff;
  font-size: 16px;
  font-weight: 800;
}

.avatar-circle {
  width: 48px;
  height: 48px;
  margin: 4px auto 0;
  border-radius: 24px;
  background: linear-gradient(135deg, #7c3aed, #4c1d95);
  border: 1px solid rgba(167, 139, 250, 0.55);
  color: #f5f3ff;
  font-size: 19px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-welcome {
  text-align: center;
  color: #f8f7ff;
  font-size: 19px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.sidebar-subtitle { text-align: center; }
.sidebar-version { text-align: center; font-size: 11px; }

.connection-pill {
  text-align: center;
  border-radius: 11px;
  padding: 6px 10px;
  font-weight: 700;
}

.connection-pill.connected {
  background-color: rgba(16, 185, 129, 0.10);
  border: 1px solid rgba(52, 211, 153, 0.43);
  color: #a7f3d0;
}

.connection-pill.offline {
  background-color: rgba(245, 158, 11, 0.10);
  border: 1px solid rgba(245, 158, 11, 0.47);
  color: #fcd34d;
}

.sidebar-spacer, .spacer { flex: 1; }

.sidebar-divider {
  height: 1px;
  background-color: #2e2a55;
  margin: 8px 0;
}

.content {
  flex: 1;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-title {
  margin: 0;
  color: #f8f7ff;
  font-size: 19px;
  font-weight: 800;
}

.refresh-badge {
  background-color: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.40);
  border-radius: 10px;
  color: #c6bef7;
  padding: 5px 11px;
  font-weight: 700;
  font-size: 11px;
}

.action-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.offline-banner {
  background-color: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.41);
  border-radius: 11px;
  color: #fde68a;
  padding: 8px 12px;
  font-weight: 700;
}

/* ============================ Stats ==================================== */

.stats-section {
  display: flex;
  gap: 10px;
}

.stat-card {
  flex: 1;
  background: linear-gradient(180deg, #191537, #110e28);
  border: 1px solid #312d58;
  border-radius: 16px;
  min-height: 72px;
  padding: 10px 14px;
}

.stat-caption {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-dot {
  width: 14px;
  height: 14px;
  border-radius: 7px;
  display: inline-block;
}

.stat-dot.total { background-color: var(--primary); }
.stat-dot.active { background-color: var(--active-green); }
.stat-dot.inactive { background-color: var(--inactive-red); }

.stat-value {
  color: #f8f7ff;
  font-size: 24px;
  font-weight: 800;
  margin-top: 2px;
}

/* ============================ Table ==================================== */

.table-wrap {
  flex: 1;
  min-height: 240px;
  overflow: auto;
  background-color: var(--table-bg);
  border: 1px solid #292449;
  border-radius: 14px;
}

.accounts-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.accounts-table thead th {
  background-color: #141130;
  color: #bdb7ea;
  padding: 9px 10px;
  font-weight: 800;
  font-size: 11px;
  text-align: left;
  border-bottom: 1px solid #2c2852;
  white-space: nowrap;
}

.accounts-table td {
  padding: 8px 10px;
  color: var(--text);
  border-bottom: 1px solid #1f1b3c;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

.accounts-table tr:last-child td { border-bottom: none; }

.accounts-table tbody tr.row-active { background-color: var(--row-active); }
.accounts-table tbody tr.row-inactive { background-color: var(--row-inactive); }
.accounts-table tbody tr.row-pending { background-color: var(--row-pending); }

.accounts-table tbody tr:hover { background-color: var(--selection-bg); }

.accounts-table input[type="checkbox"] { accent-color: var(--primary); cursor: pointer; }

.accounts-table .cell-input {
  background-color: rgba(24, 21, 50, 0.59);
  border: 1px solid #4a4478;
  border-radius: 8px;
  color: var(--text);
  padding: 4px 8px;
  font-size: 12px;
  min-width: 100%;
  outline: none;
}

.accounts-table .cell-input:focus { border-color: var(--primary); }

.accounts-table .cell-input:disabled { color: #6d6798; }

/* Status badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 10px;
  padding: 4px 11px;
  font-weight: 800;
  font-size: 11px;
}

.status-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 4px;
  box-shadow: 0 0 0 1.2px currentColor;
  opacity: 0.85;
}

.status-badge.active {
  background-color: rgba(16, 185, 129, 0.16);
  border: 1px solid rgba(52, 211, 153, 0.55);
  color: #86efac;
}

.status-badge.inactive {
  background-color: rgba(239, 68, 68, 0.16);
  border: 1px solid rgba(248, 113, 113, 0.50);
  color: #fca5a5;
}

.status-badge.pending {
  background-color: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(96, 165, 250, 0.50);
  color: #bae6fd;
}

/* Row action buttons */
.row-btn {
  border-radius: 9px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 9px;
  cursor: pointer;
  white-space: nowrap;
}

.row-btn:disabled { color: #6d6798; cursor: not-allowed; }

.row-btn-edit {
  background-color: #211d44;
  border: 1px solid #3a3565;
  color: #c6c1f0;
}

.row-btn-edit:hover { background-color: #2c2754; }

.row-btn-save {
  background: linear-gradient(180deg, var(--primary), var(--primary-deep));
  border: 1px solid var(--primary-pressed);
  color: #fff;
}

.row-btn-cancel {
  background-color: #211d44;
  border: 1px solid #3a3565;
  color: #c6c1f0;
}

.row-btn-cancel:hover { background-color: #2c2754; }

.no-results { text-align: center; padding: 12px; }

/* ============================ Toast ==================================== */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background-color: #1b1738;
  border: 1px solid #443e7c;
  color: #eae8fb;
  border-radius: 12px;
  padding: 11px 18px;
  font-weight: 700;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 60;
  max-width: 80vw;
  text-align: center;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.success { border-color: rgba(52, 211, 153, 0.55); color: #a7f3d0; }
.toast.error { border-color: rgba(248, 113, 113, 0.55); color: #fca5a5; }

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(2, 1, 12, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-card {
  width: 100%;
  max-width: 380px;
  background: linear-gradient(180deg, #1c1840, #0f0d26);
  border: 1px solid #37315f;
  border-radius: 18px;
  padding: 22px;
}

.modal-title { margin: 0 0 8px; color: #f8f7ff; font-size: 16px; font-weight: 800; }
.modal-message { margin: 0 0 16px; color: var(--text); white-space: pre-wrap; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ============================ Scrollbars =============================== */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #3a3566; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #504a94; }
