:root {
  --bg-color: #0b0c10;
  --panel-bg: rgba(22, 24, 37, 0.7);
  --border-color: rgba(255, 255, 255, 0.08);
  --primary-color: #6366f1;
  --primary-glow: rgba(99, 102, 241, 0.3);
  --success-color: #10b981;
  --success-glow: rgba(16, 185, 129, 0.2);
  --error-color: #ef4444;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Ambient Glow Effects */
.glass-bg {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -1;
  background: 
    radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.1) 0%, transparent 40%);
  filter: blur(80px);
  pointer-events: none;
}

.app-container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* Login Page Styles */
.login-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  width: 100%;
  padding: 1.5rem;
  z-index: 10;
  position: relative;
}

.login-card {
  width: 100%;
  max-width: 440px;
  padding: 2.5rem !important;
  border-radius: 16px !important;
  animation: cardFadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.login-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  border-bottom: none !important;
  padding-bottom: 0 !important;
  margin-bottom: 0.25rem !important;
  justify-content: center;
}

@keyframes cardFadeIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1.5rem;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  font-size: 2.2rem;
  animation: float 4s ease-in-out infinite;
}

.header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.badge {
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--primary-color);
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  letter-spacing: normal;
  text-transform: uppercase;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

/* Navigation Tabs */
.tab-nav {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
  flex-wrap: wrap;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.75rem 1.25rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

.tab-btn.active {
  color: white;
  background: var(--primary-color);
  box-shadow: 0 4px 12px var(--primary-glow);
}

/* Tab Content Visibility */
.tab-content {
  display: none;
  animation: fadeIn 0.3s ease-in-out;
}

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

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

/* Buttons */
.btn {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.65rem 1.25rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px var(--primary-glow);
  background-color: #5558e6;
}

.btn-primary:active {
  transform: translateY(0);
}

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

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

.btn-danger {
  background-color: rgba(239, 68, 68, 0.15);
  color: var(--error-color);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

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

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

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  border-radius: 6px;
}

/* Metrics Cards */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.card {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
}

.metric-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.metric-card:hover {
  transform: translateY(-4px);
  border-color: rgba(99, 102, 241, 0.3);
}

.metric-icon {
  font-size: 2rem;
  background: rgba(255, 255, 255, 0.04);
  padding: 0.6rem;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.metric-info h3 {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metric-info p {
  font-size: 1.4rem;
  font-weight: 700;
  margin-top: 0.25rem;
}

.status-online {
  color: var(--success-color);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.status-dot {
  width: 10px;
  height: 10px;
  background-color: var(--success-color);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--success-color);
  display: inline-block;
  animation: pulse 2s infinite;
}

/* Layouts */
.main-content {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.5rem;
  align-items: start;
}

.management-grid {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 900px) {
  .main-content, .management-grid {
    grid-template-columns: 1fr;
  }
}

/* Cards Headers */
.card h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Data Table */
.table-container {
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

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

.data-table th, .data-table td {
  padding: 1rem;
}

.data-table th {
  background-color: rgba(255, 255, 255, 0.02);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1.5px solid var(--border-color);
}

.data-table td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 0.95rem;
  vertical-align: middle;
}

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

.data-table tr:hover td {
  background-color: rgba(255, 255, 255, 0.015);
}

.table-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 4rem 1rem !important;
}

/* Row elements styling */
.tag-site {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  background-color: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.tag-selector-type {
  display: inline-block;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  background-color: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.tag-selector-type.xpath {
  background-color: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.2);
}

.tag-selector-type.opet {
  background-color: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.2);
}

.item-title {
  color: var(--text-main);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s ease;
  line-height: 1.4;
}

.item-title[href]:hover {
  color: var(--primary-color);
}

.item-link {
  color: #3b82f6;
  text-decoration: none;
  font-size: 0.85rem;
  word-break: break-all;
  display: inline-block;
  max-width: 250px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-link:hover {
  text-decoration: underline;
}

.item-date {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Sidebar Config Lists */
.config-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.config-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  padding: 0.85rem;
  border-radius: 8px;
}

.config-name {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.config-url {
  font-size: 0.8rem;
  color: var(--text-muted);
  word-break: break-all;
  margin-bottom: 0.4rem;
  display: block;
  text-decoration: none;
}

.config-url:hover {
  text-decoration: underline;
}

.config-selector {
  font-family: monospace;
  font-size: 0.75rem;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  color: #e2e8f0;
  word-break: break-all;
  display: inline-block;
  margin-top: 0.25rem;
}

/* Forms styling */
.form-container {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

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

.form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

.form-container input[type="text"],
.form-container input[type="url"],
.form-container input[type="password"],
.form-container select {
  background: #161825;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  outline: none;
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-container input:focus,
.form-container select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.15);
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-main);
  cursor: pointer;
  font-size: 0.85rem;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

/* Visibility Utilities */
.hidden {
  display: none !important;
}

/* Selector Test Box */
.test-result {
  margin-top: 1.25rem;
  background: rgba(99, 102, 241, 0.05);
  border: 1px solid rgba(99, 102, 241, 0.15);
  padding: 1rem;
  border-radius: 8px;
  animation: slideDown 0.2s ease-out;
}

.test-result h4 {
  font-size: 0.85rem;
  color: #818cf8;
  margin-bottom: 0.4rem;
}

.test-result pre {
  font-family: monospace;
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-main);
  background: rgba(0, 0, 0, 0.2);
  padding: 0.5rem;
  border-radius: 4px;
}

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

/* API Key display box */
.new-key-box {
  margin-top: 1.25rem;
  background: rgba(16, 185, 129, 0.05);
  border: 1px solid rgba(16, 185, 129, 0.15);
  padding: 1.25rem;
  border-radius: 8px;
  animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.new-key-title {
  font-size: 0.85rem;
  color: var(--success-color);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.copy-box {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  border: 1px solid rgba(16, 185, 129, 0.1);
  margin-bottom: 0.5rem;
}

.copy-box code {
  flex: 1;
  font-family: monospace;
  font-size: 0.85rem;
  color: white;
  word-break: break-all;
}

.new-key-warning {
  font-size: 0.75rem;
  color: #fca5a5;
  line-height: 1.4;
}

/* API Docs integration */
.usage-docs-card p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.doc-code-examples {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 768px) {
  .doc-code-examples {
    grid-template-columns: 1fr;
  }
}

.doc-code-examples .example {
  background: rgba(0, 0, 0, 0.2);
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.doc-code-examples h4 {
  font-size: 0.85rem;
  color: var(--text-main);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.doc-code-examples pre {
  font-family: monospace;
  font-size: 0.8rem;
  color: #a78bfa;
  white-space: pre-wrap;
  word-break: break-all;
}

.doc-code-examples .highlight {
  color: #34d399;
  font-weight: bold;
}

/* Toast Notifications */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background-color: #1f2937;
  color: var(--text-main);
  border-left: 4px solid var(--primary-color);
  padding: 1rem 1.5rem;
  border-radius: 6px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
  z-index: 1000;
  transform: translateY(150%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 500;
}

.toast.show {
  transform: translateY(0);
}

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

.toast.error {
  border-left-color: var(--error-color);
}

/* Animations */
@keyframes float {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-6px); }
  100% { transform: translateY(0px); }
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.spinning {
  display: inline-block;
  animation: rotate 1s linear infinite;
}

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