/* Style configuration variables */
:root {
  --font-main: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'Fira Code', 'Courier New', Courier, monospace;

  /* Theme color tokens - Sleek Dark Mode */
  --bg-primary: #0a0e1a;
  --bg-secondary: #0f152b;
  --bg-card: rgba(18, 26, 54, 0.45);
  --bg-input: rgba(30, 41, 79, 0.4);
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(0, 180, 216, 0.5);
  
  --text-main: #f1f3f9;
  --text-muted: #8e9bb8;
  --text-highlight: #00f2fe;

  --accent-primary: #00f2fe;      /* Electric Cyan */
  --accent-secondary: #4facfe;    /* Bright Blue */
  --accent-magenta: #ff0844;      /* Magenta/Red for notifications */
  --accent-green: #38ef7d;        /* Emerald for active status */
  --accent-purple: #7f00ff;       /* Royal Purple */
  
  --glow-cyan: rgba(0, 242, 254, 0.15);
  --glow-green: rgba(56, 239, 125, 0.25);
  --shadow-main: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
}

/* Base resets & layout */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  max-width: 100%;
  overflow-x: hidden;
  position: relative;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-main);
  min-height: 100vh;
}

/* Ambient glow backgrounds */
.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(100px);
  z-index: -1;
  pointer-events: none;
  opacity: 0.45;
}

.bg-glow-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--accent-purple) 0%, rgba(0,0,0,0) 70%);
  top: -100px;
  right: -50px;
}

.bg-glow-2 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--accent-secondary) 0%, rgba(0,0,0,0) 70%);
  bottom: -150px;
  left: -100px;
}

/* Container */
.app-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 24px;
}

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

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-area h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.logo-area h1 span {
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.global-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.pulse-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--text-muted);
  position: relative;
}

.pulse-indicator.active {
  background-color: var(--accent-green);
  box-shadow: 0 0 12px var(--accent-green);
  animation: pulse-ring 2s infinite;
}

.pulse-indicator.scanning {
  background-color: var(--accent-primary);
  box-shadow: 0 0 12px var(--accent-primary);
  animation: pulse-ring-fast 1s infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(56, 239, 125, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(56, 239, 125, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(56, 239, 125, 0); }
}

@keyframes pulse-ring-fast {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 242, 254, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(0, 242, 254, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 242, 254, 0); }
}

/* Icons */
.icon {
  width: 18px;
  height: 18px;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-title {
  width: 20px;
  height: 20px;
  color: var(--accent-primary);
}

/* Status Cards Row */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.status-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-main);
  transition: transform 0.3s ease, border-color 0.3s ease;
}

.status-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.15);
}

.status-label {
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.status-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
}

#card-status.active { border-color: rgba(56, 239, 125, 0.3); }
#card-status.scanning { border-color: rgba(0, 242, 254, 0.4); }

/* Main Content Workspace */
.main-content {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
  flex: 1;
}

/* Panels Styling */
.sidebar-panel {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.center-panel {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0; /* Prevents flex children from breaking width */
}

/* Frosted glass cards */
.glass-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 24px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-main);
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
}

.flex-expand {
  flex: 1;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-main);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 12px;
}

/* Forms & inputs */
.form-group {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

input[type="text"],
input[type="number"],
input[type="url"],
select {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 14px;
  width: 100%;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(0, 242, 254, 0.15);
}

select option {
  background-color: var(--bg-secondary);
  color: var(--text-main);
}

.form-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.3;
}

/* Switches / Toggles */
.toggle-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 16px 0;
  padding: 12px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.switch-container {
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  gap: 12px;
}

.switch-container input {
  display: none;
}

.switch-slider {
  position: relative;
  width: 42px;
  height: 22px;
  background-color: #243054;
  border-radius: 34px;
  transition: background-color 0.3s ease;
}

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

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

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

.switch-label {
  font-size: 14px;
  color: var(--text-main);
}

/* Buttons */
.btn {
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.2s ease, opacity 0.2s, box-shadow 0.2s;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--accent-secondary) 0%, var(--accent-purple) 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(127, 0, 255, 0.2);
}

.btn-primary:hover {
  opacity: 0.95;
  box-shadow: 0 4px 20px rgba(127, 0, 255, 0.4);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  color: #050811;
  box-shadow: 0 4px 15px rgba(0, 242, 254, 0.2);
}

.btn-accent:hover {
  opacity: 0.95;
  box-shadow: 0 4px 20px rgba(0, 242, 254, 0.4);
}

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

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

.btn-full {
  width: 100%;
}

.settings-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 8px;
}

.section-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 12px;
}

.section-header-row .section-title {
  margin-bottom: 0;
  border-bottom: none;
  padding-bottom: 0;
}

.btn-danger-link {
  background: transparent;
  color: var(--accent-magenta);
  font-size: 13px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-danger-link:hover {
  text-decoration: underline;
  opacity: 0.8;
}

/* Search Items List in Sidebar */
.search-list-wrapper {
  margin-top: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.search-list-wrapper h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.search-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 250px;
  overflow-y: auto;
  padding-right: 4px;
}

.search-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: background-color 0.2s;
}

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

.search-item-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0; /* handles text truncate */
  flex: 1;
}

.search-item-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-item-price {
  font-size: 11px;
  color: var(--text-muted);
}

.search-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon-del {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.2s, background-color 0.2s;
}

.btn-icon-del:hover {
  color: var(--accent-magenta);
  background: rgba(255, 8, 68, 0.1);
}

.btn-icon-edit {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.2s, background-color 0.2s;
}

.btn-icon-edit:hover {
  color: var(--accent-primary);
  background: rgba(0, 242, 254, 0.1);
}

/* Custom Scrollbar for inner components */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 10px;
}

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

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

/* Empty Matches State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 40px;
  text-align: center;
  color: var(--text-muted);
  gap: 16px;
  flex: 1;
}

.empty-icon {
  width: 64px;
  height: 64px;
  color: rgba(255, 255, 255, 0.1);
}

/* Matches Grid Area */
.matches-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  overflow-y: auto;
  max-height: 520px;
  padding-right: 4px;
}

/* Matches Card Details */
.match-card {
  background: rgba(18, 26, 54, 0.3);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), border-color 0.3s, box-shadow 0.3s;
  animation: card-appear 0.4s ease-out;
}

.match-card:hover {
  transform: translateY(-4px);
  border-color: rgba(0, 242, 254, 0.3);
  box-shadow: 0 10px 24px rgba(0, 242, 254, 0.08);
}

@keyframes card-appear {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.match-image-container {
  height: 160px;
  width: 100%;
  background-color: rgba(255, 255, 255, 0.02);
  position: relative;
  overflow: hidden;
}

.match-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.match-card:hover .match-img {
  transform: scale(1.04);
}

.match-img-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.08);
}

.match-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(10, 14, 26, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  backdrop-filter: blur(4px);
}

.match-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.match-time {
  font-size: 11px;
  color: var(--text-muted);
}

.match-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-main);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  height: 38px;
}

.match-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
}

.match-price {
  font-size: 18px;
  font-weight: 800;
  color: var(--accent-primary);
}

.match-location {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
  text-align: right;
}

.match-footer {
  padding: 0 16px 16px;
  margin-top: auto;
}

/* Console Logs Terminal Box */
.terminal-container {
  background: #050811;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px;
  height: 160px;
  display: flex;
}

.terminal-body {
  font-family: var(--font-mono);
  font-size: 12px;
  color: #a9b7c6;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
}

.terminal-body .log-entry {
  margin-bottom: 2px;
}

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

/* Responsive Grid & Mobile Optimization */
@media (max-width: 1024px) {
  .app-container {
    padding: 12px;
  }
  
  .app-header {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    padding-bottom: 16px;
    margin-bottom: 16px;
    text-align: center;
  }
  
  .logo-area {
    justify-content: center;
  }
  
  .global-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    width: 100%;
  }

  .main-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
  
  /* UX ordering: Matches section and console terminal logs go first, settings and queries go below */
  .center-panel {
    order: 1;
    gap: 16px;
  }
  
  .sidebar-panel {
    order: 2;
    gap: 16px;
  }

  .status-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
  }

  .status-card {
    padding: 12px;
    border-radius: 12px;
  }

  .status-label {
    font-size: 11px;
    margin-bottom: 4px;
  }

  .status-value {
    font-size: 15px;
    word-break: break-all;
  }

  .glass-section {
    padding: 16px;
    border-radius: 16px;
  }

  .section-title {
    font-size: 16px;
    margin-bottom: 14px;
    padding-bottom: 8px;
  }

  .matches-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    max-height: 480px;
  }

  .match-card {
    border-radius: 12px;
  }

  .match-image-container {
    height: 140px;
  }

  .match-body {
    padding: 12px;
    gap: 6px;
  }

  .match-title {
    font-size: 13px;
    height: auto;
    max-height: 36px;
    -webkit-line-clamp: 2;
  }

  .match-price {
    font-size: 16px;
  }
  
  .match-footer {
    padding: 0 12px 12px;
  }

  .terminal-container {
    height: 120px;
    padding: 10px;
  }

  .terminal-body {
    font-size: 11px;
  }
}

/* Tablet & Mobile Admin Table Card layout */
@media (max-width: 768px) {
  .admin-table, 
  .admin-table thead, 
  .admin-table tbody, 
  .admin-table th, 
  .admin-table td, 
  .admin-table tr {
    display: block;
  }
  
  .admin-table thead {
    display: none; /* Hide table headers */
  }
  
  .admin-table tr {
    margin-bottom: 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
  }
  
  .admin-table td {
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    padding: 10px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: right;
  }
  
  .admin-table td:last-child {
    border-bottom: none;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  .admin-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  
  .user-action-btn-row {
    width: 100%;
    justify-content: space-between;
    margin-top: 4px;
    gap: 6px;
  }
  
  .user-action-btn-row .btn-small-action,
  .user-action-btn-row .btn-small-danger {
    flex: 1;
    text-align: center;
    justify-content: center;
    padding: 8px;
    font-size: 12px;
  }
}

@media (max-width: 580px) {
  .global-actions {
    flex-direction: column;
    width: 100%;
    gap: 8px !important;
  }
  
  .global-actions .btn,
  .global-actions .user-tag {
    width: 100% !important;
    text-align: center;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .status-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .form-row {
    grid-template-columns: 1fr;
    gap: 12px; /* Space between stacked inputs */
  }
  
  .settings-buttons {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

/* SaaS & Auth View Enhancements */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 32px;
}

.error-msg {
  color: var(--accent-magenta);
  background: rgba(255, 8, 68, 0.08);
  border: 1px solid rgba(255, 8, 68, 0.2);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-top: 14px;
  text-align: center;
  animation: shake 0.3s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.user-tag {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
}

.table-container {
  overflow-x: auto;
  width: 100%;
  margin-top: 10px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  text-align: left;
}

.admin-table th {
  color: var(--text-muted);
  font-weight: 600;
  padding: 12px;
  border-bottom: 1px solid var(--border-color);
}

.admin-table td {
  padding: 14px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
}

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

input[type="password"],
input[type="date"] {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 14px;
  width: 100%;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="password"]:focus,
input[type="date"]:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(0, 242, 254, 0.15);
}

.user-action-btn-row {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.btn-small-danger {
  background: rgba(255, 8, 68, 0.1);
  color: var(--accent-magenta);
  font-size: 11px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 8, 68, 0.2);
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-small-danger:hover {
  background: rgba(255, 8, 68, 0.2);
}

.btn-small-action {
  background: rgba(0, 242, 254, 0.1);
  color: var(--accent-primary);
  font-size: 11px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(0, 242, 254, 0.2);
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-small-action:hover {
  background: rgba(0, 242, 254, 0.2);
}


