/* BGP Configurator - Professional Styles */
:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --secondary: #64748b;
  --secondary-hover: #475569;
  --success: #10b981;
  --success-light: #d1fae5;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --background: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --border: #e2e8f0;
  --border-focus: #2563eb;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius: 0.5rem;
  --radius-sm: 0.375rem;
  --radius-lg: 0.75rem;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--background);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* Layout */
.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-brand svg {
  width: 32px;
  height: 32px;
  color: var(--primary);
}

.header-brand h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

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

.header-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.header-nav a:hover {
  color: var(--text-primary);
  background: var(--surface-alt);
}

.header-nav a.active {
  color: var(--primary);
  background: var(--primary-light);
}

.header-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-left: 1rem;
  border-left: 1px solid var(--border);
}

.header-user span {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.main-content {
  flex: 1;
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* Login Page */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  background: linear-gradient(135deg, #1e3a5f 0%, #0f172a 100%);
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-header svg {
  width: 48px;
  height: 48px;
  color: var(--primary);
  margin-bottom: 1rem;
}

.login-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.login-header p {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-primary);
  transition: all 0.15s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group input.error,
.form-group select.error {
  border-color: var(--danger);
}

.form-group .error-message {
  color: var(--danger);
  font-size: 0.75rem;
  margin-top: 0.25rem;
  display: none;
}

.form-group .error-message.visible {
  display: block;
}

.form-group .help-text {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

/* Toggle Switch */
.toggle-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s ease;
}

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

.toggle-slider {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: var(--surface);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease;
}

.toggle input:checked + .toggle-slider {
  transform: translateX(20px);
}

.toggle input:checked ~ .toggle {
  background: var(--primary);
}

.toggle:has(input:checked) {
  background: var(--primary);
}

.toggle-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

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

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

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface-alt);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border);
}

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

.btn-success:hover:not(:disabled) {
  background: #059669;
}

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

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-outline:hover:not(:disabled) {
  background: var(--primary-light);
}

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

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

.btn-full {
  width: 100%;
}

.btn-group {
  display: flex;
  gap: 0.75rem;
}

/* Alerts */
.alert {
  padding: 0.875rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.alert svg {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.alert-success {
  background: var(--success-light);
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.alert-danger {
  background: var(--danger-light);
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-warning {
  background: var(--warning-light);
  color: #92400e;
  border: 1px solid #fde68a;
}

.alert-info {
  background: var(--primary-light);
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}

.card-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
}

.card-header p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.card-body {
  padding: 1.5rem;
}

.card-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Configurator Layout */
.configurator-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .configurator-layout {
    grid-template-columns: 1fr;
  }
}

.config-form {
  position: sticky;
  top: 5rem;
}

/* Output Panel */
.output-panel {
  background: #0f172a;
  border-radius: var(--radius);
  overflow: hidden;
}

.output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: #1e293b;
  border-bottom: 1px solid #334155;
}

.output-header h3 {
  color: #e2e8f0;
  font-size: 0.875rem;
  font-weight: 500;
}

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

.output-actions button {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  background: #334155;
  color: #e2e8f0;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease;
}

.output-actions button:hover {
  background: #475569;
}

.output-actions button svg {
  width: 14px;
  height: 14px;
}

.output-content {
  padding: 1.25rem;
  min-height: 300px;
  max-height: 600px;
  overflow-y: auto;
}

.output-content pre {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.7;
  color: #e2e8f0;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
}

.output-content .placeholder {
  color: #64748b;
  font-style: italic;
  text-align: center;
  padding: 3rem 1rem;
}

/* Settings Page */
.settings-grid {
  display: grid;
  gap: 1.5rem;
  max-width: 600px;
}

.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.settings-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.settings-section h3 span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
}

.inline-form {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.inline-form .form-group {
  flex: 1;
  margin-bottom: 0;
}

/* Page Header */
.page-header {
  margin-bottom: 2rem;
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.page-header p {
  color: var(--text-secondary);
}

/* Config Tabs */
.config-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  background: var(--surface);
  padding: 0.25rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  width: fit-content;
}

.tab-btn {
  padding: 0.625rem 1.25rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--surface-alt);
}

.tab-btn.active {
  background: var(--primary);
  color: white;
}

/* Validation Summary */
.validation-summary {
  background: var(--danger-light);
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 1rem;
}

.validation-summary h4 {
  color: #991b1b;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.validation-summary ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.validation-summary li {
  color: #991b1b;
  font-size: 0.8125rem;
  padding: 0.25rem 0;
}

.validation-summary li::before {
  content: "•";
  margin-right: 0.5rem;
}

/* Copy notification */
.copy-notification {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--success);
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  opacity: 0;
  transform: translateY(1rem);
  transition: all 0.3s ease;
  z-index: 1000;
}

.copy-notification.visible {
  opacity: 1;
  transform: translateY(0);
}

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

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

/* Hidden utility */
.hidden {
  display: none !important;
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 9999px;
}

.badge-admin {
  background: var(--primary-light);
  color: var(--primary);
}

.badge-user {
  background: var(--surface-alt);
  color: var(--text-secondary);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}

.tab {
  padding: 0.75rem 1.5rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-secondary);
  position: relative;
  transition: color 0.2s;
}

.tab:hover {
  color: var(--text-primary);
}

.tab.active {
  color: var(--primary);
}

.tab.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
}

.tab-content {
  animation: fadeIn 0.2s ease;
}

.tab-content.hidden {
  display: none;
}

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

.section-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

/* Data list */
.data-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.data-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: box-shadow 0.2s;
}

.data-item:hover {
  box-shadow: var(--shadow);
}

.data-item-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.data-item-badge {
  padding: 0.25rem 0.75rem;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 600;
}

.data-item-badge.badge-admin {
  background: var(--success-light);
  color: var(--success);
}

.data-item-badge.badge-user {
  background: var(--surface-alt);
  color: var(--text-secondary);
}

.data-item-name {
  font-weight: 500;
}

.data-item-detail {
  color: var(--text-muted);
  font-size: 0.875rem;
}

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

.inline-edit {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.asn-edit-input {
  width: 140px;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}

.role-select {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  background: var(--surface);
  cursor: pointer;
}

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

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 450px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease;
}

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

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

.modal-header h3 {
  font-size: 1.125rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 0;
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-content form {
  padding: 1.5rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* Settings page specific */
.settings-page .main-content {
  max-width: 900px;
}

/* Responsive */
@media (max-width: 768px) {
  .data-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .data-item-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .inline-edit {
    width: 100%;
  }

  .asn-edit-input {
    flex: 1;
  }
}

@media (max-width: 640px) {
  .header {
    padding: 0.75rem 1rem;
  }
  
  .main-content {
    padding: 1rem;
  }
  
  .btn-group {
    flex-direction: column;
  }
  
  .inline-form {
    flex-direction: column;
  }

  .tabs {
    overflow-x: auto;
  }

  .tab {
    padding: 0.5rem 1rem;
    white-space: nowrap;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
}
