/* ==========================================================================
   MudaRemote Web Manager - Modern Glassmorphic Dark Design System
   ========================================================================== */

:root {
  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Color Palette */
  --bg-dark: #090d16;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(26, 36, 56, 0.85);
  --bg-input: rgba(13, 19, 33, 0.9);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: #06b6d4;

  --accent-cyan: #06b6d4;
  --accent-cyan-glow: rgba(6, 182, 212, 0.25);
  --accent-purple: #8b5cf6;
  --accent-discord: #5865f2;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(6, 182, 212, 0.35);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body.dark-theme {
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(at 0% 0%, rgba(88, 101, 242, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(6, 182, 212, 0.1) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: var(--font-main);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Glassmorphism Card Utility */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

/* App Layout */
.app-layout {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 3rem 1.5rem;
}

/* Top Navbar */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1.5rem;
  margin-bottom: 1.25rem;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  object-fit: cover;
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.3);
}

.brand-title h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff 30%, var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
  margin-right: 0.4rem;
}

.version-tag {
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-weight: 500;
}

.nav-center {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.status-indicator-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.status-running {
  background: var(--accent-emerald);
  box-shadow: 0 0 10px var(--accent-emerald);
  animation: pulse-dot 2s infinite;
}

.status-dot.status-stopped {
  background: var(--accent-rose);
}

.status-dot.status-starting {
  background: var(--accent-amber);
  animation: pulse-dot 1s infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.quick-controls {
  display: flex;
  gap: 0.4rem;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Update Alert Banner */
.update-banner {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.15), rgba(6, 182, 212, 0.15));
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius-lg);
  padding: 0.75rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.15);
  animation: slideDown 0.3s ease-out;
}

.banner-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.banner-text {
  font-weight: 500;
  font-size: 0.95rem;
  color: #fef3c7;
}

.banner-actions {
  display: flex;
  gap: 0.5rem;
}

/* Navigation Tabs Bar */
.nav-tabs-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.75rem;
  overflow-x: auto;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.6rem 1.15rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
  color: #fff;
  background: rgba(6, 182, 212, 0.15);
  border: 1px solid rgba(6, 182, 212, 0.3);
  font-weight: 600;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.25s ease-out;
}

/* Dashboard Tab Styles */
.dashboard-grid {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}

.stat-card {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
}

.stat-sub {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
}

/* Live Terminal Card */
.terminal-card {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.terminal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1.25rem;
  background: rgba(10, 15, 26, 0.95);
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.terminal-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.terminal-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
}
.terminal-dot.red { background: #ef4444; }
.terminal-dot.yellow { background: #eab308; }
.terminal-dot.green { background: #22c55e; }

.terminal-name {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-left: 0.5rem;
}

.terminal-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.terminal-body {
  height: 480px;
  background: #06090e;
  padding: 1rem 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  overflow-y: auto;
  line-height: 1.6;
  color: #d1d5db;
}

.log-line {
  word-break: break-all;
  white-space: pre-wrap;
}

.log-line.log-error { color: #f87171; }
.log-line.log-warn { color: #fde047; }
.log-line.log-claim { color: #34d399; font-weight: 500; }
.log-line.log-kakera { color: #60a5fa; }

/* Preset Editor Layout */
.preset-editor-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.5rem;
}

.preset-sidebar {
  padding: 1.25rem;
  height: fit-content;
  max-height: 750px;
  display: flex;
  flex-direction: column;
}

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

.sidebar-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.preset-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  overflow-y: auto;
}

.preset-item {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.preset-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.preset-item.active {
  background: rgba(6, 182, 212, 0.12);
  border-color: rgba(6, 182, 212, 0.3);
  color: #fff;
  font-weight: 600;
}

.preset-form-container {
  padding: 1.5rem 2rem;
}

.form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.form-title-group h2 {
  font-size: 1.4rem;
  font-weight: 700;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
}

/* Subtabs */
.subtabs-bar {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1.75rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.subtab-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.5rem 0.95rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.subtab-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.subtab-btn.active {
  background: var(--accent-cyan);
  color: #000;
  font-weight: 600;
  border-color: var(--accent-cyan);
}

.subtab-content {
  display: none;
}

.subtab-content.active {
  display: block;
  animation: fadeIn 0.2s ease-out;
}

/* Form Inputs Grid */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

.col-span-2 {
  grid-column: span 2;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.input-group label {
  font-size: 0.88rem;
  font-weight: 500;
  color: #e5e7eb;
}

.req {
  color: var(--accent-rose);
}

.field-hint {
  font-size: 0.76rem;
  color: var(--text-dim);
}

input[type="text"],
input[type="password"],
input[type="url"],
input[type="number"],
textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: #fff;
  font-family: var(--font-main);
  font-size: 0.92rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  transition: var(--transition);
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-cyan-glow);
}

.password-input-wrap {
  position: relative;
  display: flex;
}

.password-input-wrap input {
  width: 100%;
  padding-right: 2.75rem;
}

.btn-reveal {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: var(--radius-sm);
}

.btn-reveal:hover {
  color: #fff;
}

/* Custom Switches */
.switch-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  padding: 0.9rem 1.15rem;
  border-radius: var(--radius-md);
}

.switch-label {
  font-size: 0.92rem;
  font-weight: 600;
  color: #fff;
}

.switch-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: .3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--accent-cyan);
}

input:checked + .slider:before {
  transform: translateX(20px);
  background-color: #000;
}

/* Buttons */
.btn {
  font-family: var(--font-main);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.55rem 1.15rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent-cyan);
  color: #000;
}
.btn-primary:hover {
  background: #22d3ee;
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.4);
}

.btn-success {
  background: var(--accent-emerald);
  color: #000;
}
.btn-success:hover {
  background: #34d399;
}

.btn-danger {
  background: var(--accent-rose);
  color: #fff;
}
.btn-danger:hover {
  background: #fb7185;
}

.btn-warning {
  background: var(--accent-amber);
  color: #000;
  font-weight: 700;
}
.btn-warning:hover {
  background: #fbbf24;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
}
.btn-outline:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.btn-danger-text {
  color: var(--accent-rose);
  border-color: rgba(244, 63, 94, 0.3);
}
.btn-danger-text:hover {
  background: rgba(244, 63, 94, 0.1);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
}
.btn-icon:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

/* Badges */
.badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-warning {
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.pulse {
  animation: pulse-badge 1.5s infinite;
}

@keyframes pulse-badge {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.7; }
  100% { transform: scale(1); opacity: 1; }
}

/* Raw Editor Tab */
.raw-editor-card {
  padding: 1.5rem 2rem;
}

.raw-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.raw-actions {
  display: flex;
  gap: 0.5rem;
}

.raw-body textarea {
  width: 100%;
  height: 580px;
  background: #06090e;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.6;
  padding: 1.25rem;
}

/* Backups Tab Table */
.backups-card {
  padding: 1.5rem 2rem;
}

.backups-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.backups-table-wrap {
  overflow-x: auto;
}

.backups-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.backups-table th,
.backups-table td {
  padding: 0.85rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.backups-table th {
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
}

.text-right {
  text-align: right;
}

/* Alerts */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  margin-top: 0.75rem;
}

.alert-danger {
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid rgba(244, 63, 94, 0.35);
  color: #fecdd3;
}

.alert-info {
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.3);
  color: #cffafe;
}

/* Modal Backdrop */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 1rem;
  animation: fadeIn 0.2s ease-out;
}

.modal-card {
  width: 100%;
  max-width: 540px;
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 1.75rem;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.25rem;
}

.changelog-box {
  background: #06090e;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  max-height: 220px;
  overflow-y: auto;
  margin: 1rem 0;
}

.changelog-box h4 {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.changelog-box pre {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #e5e7eb;
  white-space: pre-wrap;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* Auth Card */
.auth-card {
  max-width: 400px;
  width: 100%;
  padding: 2.25rem;
  text-align: center;
}

.auth-logo {
  width: 64px;
  height: 64px;
  margin-bottom: 1rem;
}

.auth-header h2 {
  font-size: 1.35rem;
  margin-bottom: 0.4rem;
}

.auth-card form {
  margin-top: 1.5rem;
  text-align: left;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 2000;
}

.toast {
  background: #1e293b;
  color: #fff;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
  font-size: 0.88rem;
  animation: slideLeft 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 280px;
}

.toast.toast-success { border-left: 4px solid var(--accent-emerald); }
.toast.toast-error { border-left: 4px solid var(--accent-rose); }
.toast.toast-info { border-left: 4px solid var(--accent-cyan); }

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

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideDown {
  from { transform: translateY(-15px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes slideLeft {
  from { transform: translateX(30px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Responsive Breakpoints */
@media (max-width: 960px) {
  .preset-editor-layout {
    grid-template-columns: 1fr;
  }
  
  .form-grid {
    grid-template-columns: 1fr;
  }
  
  .col-span-2 {
    grid-column: span 1;
  }
  
  .navbar {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }
  
  .nav-center {
    justify-content: space-between;
  }
}
