@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700&display=swap');

:root {
  --bg-primary: #0b0f19;
  --bg-secondary: #121824;
  --bg-glass: rgba(18, 24, 38, 0.75);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(99, 102, 241, 0.15);
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --color-primary: #6366f1; /* Indigo */
  --color-primary-hover: #4f46e5;
  --color-accent: #06b6d4; /* Cyan */
  --color-success: #10b981; /* Emerald */
  --color-danger: #ef4444; /* Red */
  --font-family-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-family-title: 'Outfit', sans-serif;
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-family-sans);
  line-height: 1.5;
  overflow-x: hidden;
  height: 100vh;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: #1f2937;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary);
}

/* Auth / Login Page Layout */
#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(circle at top right, var(--border-glow), transparent 40%),
              radial-gradient(circle at bottom left, rgba(6, 182, 212, 0.05), transparent 40%);
}

.login-card {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  animation: scaleUp 0.4s ease-out;
}

.login-card h2 {
  font-family: var(--font-family-title);
  font-size: 2rem;
  margin-bottom: 8px;
  text-align: center;
  background: linear-gradient(135deg, #fff 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-card p {
  color: var(--text-secondary);
  text-align: center;
  font-size: 0.9rem;
  margin-bottom: 28px;
}

/* Form Group Control */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-family-sans);
  font-size: 0.95rem;
  transition: all 0.2s ease-in-out;
}

.form-control:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  font-family: var(--font-family-sans);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  gap: 8px;
  text-decoration: none;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  width: 100%;
}

.btn-primary:hover {
  background: var(--color-primary-hover);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}

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

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
}

.btn-danger {
  background: var(--color-danger);
  color: #fff;
}

.btn-danger:hover {
  background: #dc2626;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
}

.btn-success {
  background: var(--color-success);
  color: #fff;
}

.btn-success:hover {
  background: #059669;
}

/* Spinner Loader */
.spinner {
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top: 3px solid var(--color-accent);
  border-radius: 50%;
  width: 18px;
  height: 18px;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

/* Dashboard App Layout */
#app-view {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Sidebar Styling */
.sidebar {
  width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-header h1 {
  font-family: var(--font-family-title);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.sidebar-menu {
  list-style: none;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
}

.menu-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  color: var(--text-secondary);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
  gap: 12px;
}

.menu-item:hover, .menu-item.active {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.menu-item.active {
  background: rgba(99, 102, 241, 0.1);
  border-left: 3px solid var(--color-primary);
  padding-left: 13px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-info {
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding-left: 8px;
}

/* Main Content Panel */
.main-panel {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: radial-gradient(circle at bottom right, rgba(99, 102, 241, 0.03), transparent 60%);
}

.panel-header {
  padding: 20px 40px;
  background: rgba(11, 15, 25, 0.3);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-header h2 {
  font-family: var(--font-family-title);
  font-size: 1.5rem;
  font-weight: 600;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.panel-body {
  padding: 40px;
  overflow-y: auto;
  flex-grow: 1;
}

.panel-section {
  display: none;
  animation: fadeIn 0.3s ease-out;
}

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

/* Grid system for Nodes/Domains */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

/* Cards style */
.glass-card {
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.glass-card:hover {
  transform: translateY(-2px);
  border-color: rgba(99, 102, 241, 0.25);
}

.card-title {
  font-family: var(--font-family-title);
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.status-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.status-active {
  background-color: var(--color-success);
  box-shadow: 0 0 8px var(--color-success);
}

.status-warning {
  background-color: #f59e0b;
  box-shadow: 0 0 8px #f59e0b;
}

.status-inactive {
  background-color: var(--color-danger);
  box-shadow: 0 0 8px var(--color-danger);
}

.card-meta {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.card-domains-list {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.card-domains-list .tag {
  display: inline-block;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 4px;
  margin: 2px;
}

.card-actions {
  margin-top: auto;
  padding-top: 16px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Custom switch iOS styling */
.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
}

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

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #2e3b52;
  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(--color-success);
}

input:checked + .slider:before {
  transform: translateX(18px);
}

/* Tables styling */
.table-container {
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.custom-table th, .custom-table td {
  padding: 16px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.custom-table th {
  background: rgba(255, 255, 255, 0.02);
  font-family: var(--font-family-title);
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.custom-table td {
  font-size: 0.9rem;
  vertical-align: middle;
}

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

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

/* Interactive elements in table */
.client-name-cell {
  display: flex;
  flex-direction: column;
}

.client-name-cell .name {
  font-weight: 600;
  color: var(--text-primary);
}

.client-name-cell .email {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.endpoints-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 400px;
}

.endpoints-box pre {
  background: rgba(0, 0, 0, 0.2);
  padding: 6px 10px;
  border-radius: 6px;
  font-family: monospace;
  font-size: 0.75rem;
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.03);
  position: relative;
  cursor: pointer;
  color: #38bdf8;
}

.endpoints-box pre:hover::after {
  content: 'Click to copy';
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.65rem;
}

/* Modal Dialog design */
dialog {
  margin: auto;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-radius: 16px;
  padding: 32px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(20px);
  outline: none;
  animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

dialog.closing {
  animation: modalOut 0.2s ease-in forwards;
}

dialog h3 {
  font-family: var(--font-family-title);
  font-size: 1.5rem;
  margin-bottom: 20px;
}

dialog form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

dialog .dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 12px;
}

.checkbox-list-container {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.15);
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  cursor: pointer;
  font-size: 0.9rem;
}

.checkbox-item input {
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary);
}

/* Keyframes animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleUp {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes modalOut {
  from { opacity: 1; transform: scale(1) translateY(0); }
  to { opacity: 0; transform: scale(0.9) translateY(20px); }
}

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

/* Responsive fixes */
@media (max-width: 900px) {
  #app-view {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  .sidebar-header {
    padding: 16px 20px;
  }
  .sidebar-menu {
    flex-direction: row;
    overflow-x: auto;
    padding: 10px 20px;
    gap: 10px;
  }
  .menu-item {
    padding: 8px 12px;
    white-space: nowrap;
  }
  .menu-item.active {
    border-left: none;
    border-bottom: 3px solid var(--color-primary);
    padding-left: 12px;
    padding-bottom: 5px;
  }
  .panel-header {
    padding: 16px 20px;
  }
  .panel-body {
    padding: 20px;
  }
}

/* Toast Notifications styling */
.toast {
  background: rgba(18, 24, 38, 0.9);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 14px 20px;
  min-width: 300px;
  max-width: 400px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  color: var(--text-primary);
  animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), toastOut 0.3s ease-in 4.7s forwards;
  pointer-events: auto;
}

.toast-success {
  border-left: 4px solid var(--color-success);
}

.toast-error {
  border-left: 4px solid var(--color-danger);
}

.toast-info {
  border-left: 4px solid var(--color-accent);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(50px) scale(0.95); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0; transform: translateY(-15px) scale(0.9); pointer-events: none; }
}
