/* ============================================================
 * Cloud Guard — Custom CSS
 * ============================================================
 * Dark theme with glassmorphism, gradients, and micro-animations.
 * Works alongside Tailwind CSS CDN.
 * ============================================================ */

/* ── CSS Variables (Design Tokens) ─────────────────────────── */
:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-card-hover: rgba(31, 41, 55, 0.8);
  --bg-glass: rgba(255, 255, 255, 0.03);
  --bg-input: rgba(255, 255, 255, 0.05);

  --border-glass: rgba(255, 255, 255, 0.08);
  --border-active: rgba(99, 102, 241, 0.5);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-indigo: #6366f1;
  --accent-violet: #8b5cf6;
  --accent-cyan: #22d3ee;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  --gradient-primary: linear-gradient(135deg, #6366f1, #8b5cf6);
  --gradient-success: linear-gradient(135deg, #10b981, #22d3ee);
  --gradient-danger: linear-gradient(135deg, #f43f5e, #fb923c);
  --gradient-bg: linear-gradient(135deg, #0a0e1a 0%, #1a1033 50%, #0a0e1a 100%);

  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-glow-indigo: 0 0 20px rgba(99, 102, 241, 0.15);
  --shadow-glow-success: 0 0 20px rgba(16, 185, 129, 0.15);
  --shadow-glow-danger: 0 0 20px rgba(244, 63, 94, 0.15);

  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;

  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;
}

/* ── Global Resets ─────────────────────────────────────────── */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

/* ── Custom Scrollbar ──────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ── Animated Background ───────────────────────────────────── */
.bg-animated {
  background: var(--gradient-bg);
  position: relative;
  overflow-x: hidden;
}

.bg-animated::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(34, 211, 238, 0.04) 0%, transparent 50%);
  animation: bgFloat 20s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

@keyframes bgFloat {

  0%,
  100% {
    transform: translate(0, 0) rotate(0deg);
  }

  33% {
    transform: translate(2%, -2%) rotate(1deg);
  }

  66% {
    transform: translate(-1%, 1%) rotate(-1deg);
  }
}

/* ── Glassmorphism Cards ───────────────────────────────────── */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  transition: all var(--transition-normal);
}

.glass-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow-card), var(--shadow-glow-indigo);
}

.glass-card-static {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

/* ── Stat Cards ────────────────────────────────────────────── */
.stat-card {
  position: relative;
  padding: 1.25rem;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.1) 0%, transparent 70%);
  transform: translate(30%, -30%);
}

.stat-card.success::after {
  background: radial-gradient(circle, rgba(16, 185, 129, 0.1) 0%, transparent 70%);
}

.stat-card.warning::after {
  background: radial-gradient(circle, rgba(245, 158, 11, 0.1) 0%, transparent 70%);
}

.stat-card.danger::after {
  background: radial-gradient(circle, rgba(244, 63, 94, 0.1) 0%, transparent 70%);
}

/* ── Circular Progress ─────────────────────────────────────── */
.progress-ring {
  transform: rotate(-90deg);
}

.progress-ring-circle {
  transition: stroke-dashoffset var(--transition-slow);
  stroke-linecap: round;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  background: rgba(10, 14, 26, 0.95);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border-glass);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition-fast);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.sidebar-link.active {
  background: rgba(99, 102, 241, 0.12);
  color: #a5b4fc;
  border-left: 3px solid var(--accent-indigo);
}

.sidebar-link i {
  width: 20px;
  text-align: center;
  font-size: 1rem;
}

/* ── Form Elements ─────────────────────────────────────────── */
.form-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  background: var(--bg-input);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: inherit;
  transition: all var(--transition-fast);
  outline: none;
}

.form-input:focus {
  border-color: var(--accent-indigo);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
  background: rgba(255, 255, 255, 0.07);
}

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

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
}

.form-textarea {
  resize: vertical;
  min-height: 120px;
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.8125rem;
  line-height: 1.6;
  tab-size: 4;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 2px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.5);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--gradient-success);
  color: white;
  box-shadow: 0 2px 12px rgba(16, 185, 129, 0.3);
}

.btn-success:hover:not(:disabled) {
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.5);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--gradient-danger);
  color: white;
  box-shadow: 0 2px 12px rgba(244, 63, 94, 0.3);
}

.btn-danger:hover:not(:disabled) {
  box-shadow: 0 4px 20px rgba(244, 63, 94, 0.5);
  transform: translateY(-1px);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid var(--border-glass);
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

/* ── Status Badges ─────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.badge-danger {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
}

.badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.badge-info {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
}

.badge-running {
  background: rgba(34, 211, 238, 0.15);
  color: #67e8f9;
}

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

.badge-success .badge-dot {
  background: #34d399;
}

.badge-danger .badge-dot {
  background: #fb7185;
}

.badge-warning .badge-dot {
  background: #fbbf24;
}

.badge-running .badge-dot {
  background: #67e8f9;
  animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.3;
  }
}

/* ── Terminal / Log Viewer ─────────────────────────────────── */
.terminal {
  background: #0d1117;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  padding: 1rem;
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.8125rem;
  line-height: 1.7;
  overflow-x: auto;
  overflow-y: auto;
  max-height: 500px;
  color: #c9d1d9;
  white-space: pre-wrap;
  word-break: break-all;
}

.terminal .log-timestamp {
  color: #8b949e;
}

.terminal .log-info {
  color: #58a6ff;
}

.terminal .log-ok {
  color: #3fb950;
}

.terminal .log-warn {
  color: #d29922;
}

.terminal .log-error {
  color: #f85149;
}

/* ── Data Table ────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.data-table thead th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-glass);
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  z-index: 1;
}

.data-table tbody td {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
}

.data-table tbody tr {
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

/* ── Tab Navigation ────────────────────────────────────────── */
.tab-nav {
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
  overflow-x: auto;
}

.tab-btn {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

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

.tab-btn.active {
  color: var(--text-primary);
  background: rgba(99, 102, 241, 0.15);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ── Toast Notifications ───────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 400px;
}

.toast {
  padding: 0.875rem 1.25rem;
  border-radius: var(--radius-md);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  animation: toastSlideIn 300ms ease forwards;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  font-size: 0.875rem;
}

.toast-success {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.3);
}

.toast-error {
  background: rgba(244, 63, 94, 0.12);
  border-color: rgba(244, 63, 94, 0.3);
}

.toast-warning {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.3);
}

.toast-info {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.3);
}

.toast-exit {
  animation: toastSlideOut 200ms ease forwards;
}

@keyframes toastSlideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toastSlideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }

  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  animation: fadeIn 150ms ease;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl);
  padding: 2rem;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  animation: modalSlideUp 200ms ease;
}

.modal-large {
  max-width: 800px !important;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes modalSlideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ── Login Specific ────────────────────────────────────────── */
.login-card {
  max-width: 420px;
  width: 90%;
  padding: 2.5rem;
}

.login-logo {
  width: 56px;
  height: 56px;
  background: var(--gradient-primary);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin: 0 auto 1.5rem;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  10%,
  30%,
  50%,
  70%,
  90% {
    transform: translateX(-4px);
  }

  20%,
  40%,
  60%,
  80% {
    transform: translateX(4px);
  }
}

.shake {
  animation: shake 0.5s ease;
}

/* ── Chip / Tag ────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 9999px;
  font-size: 0.8125rem;
  color: #a5b4fc;
}

.chip-remove {
  cursor: pointer;
  opacity: 0.6;
  font-size: 1rem;
  line-height: 1;
  transition: opacity var(--transition-fast);
}

.chip-remove:hover {
  opacity: 1;
  color: var(--accent-rose);
}

/* ── Spinner ───────────────────────────────────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 3px;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .sidebar.open {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 100;
    width: 260px;
  }

  .mobile-menu-btn {
    display: flex !important;
  }
}

/* ── Utility ───────────────────────────────────────────────── */
.fade-in {
  animation: fadeIn 300ms ease;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mono {
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

/* ── UI Enhancements ────────────────────────────────────────── */
.copy-box {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', monospace;
  padding: 0.75rem;
  font-size: 0.8125rem;
  color: #c9d1d9;
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.copy-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--text-primary);
  transition: all 150ms;
}

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

/* ── File System Browser ────────────────────────────────────── */
.fs-browser {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  max-height: 500px;
  overflow-y: auto;
  padding: 0.5rem;
}

.browser-path-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.375rem 0.5rem;
  border-bottom: 1px solid var(--border-glass);
  margin-bottom: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.browser-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.375rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 150ms;
}

.browser-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.browser-actions {
  display: flex;
  gap: 0.25rem;
}

/* ── Database Selector List ─────────────────────────────────── */
.db-select-list {
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  max-height: 500px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.2);
}

.db-select-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.db-select-item:last-child {
  border-bottom: none;
}

/* Timezone select */
select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%2394a3b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.5rem center;
  background-size: 1.5em 1.5em;
  background-repeat: no-repeat;
  padding-right: 2.5rem;
}

select.form-input option {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

/* ── Code Block Copy Buttons ───────────────────────────────── */
.code-block-wrapper:hover .copy-code-btn {
  opacity: 1 !important;
}
.copy-code-btn {
  z-index: 10;
  cursor: pointer;
  transition: all 150ms ease-in-out;
}
/* hash-salt: 0 */
