/* ============================================================
   General Purpose Proxy – Dark, minimal, modern CSS
   ============================================================ */

:root {
  --bg: #0f0f12;
  --bg-elevated: #18181b;
  --bg-hover: #1f1f23;
  --border: #27272a;
  --border-focus: #6366f1;
  --text: #e4e4e7;
  --text-muted: #a1a1aa;
  --text-faint: #71717a;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --danger: #ef4444;
  --danger-hover: #f87171;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --transition: 0.15s ease;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 100vw;
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 2px;
  padding: 8px 12px 0;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font: inherit;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
  white-space: nowrap;
}

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

.tab.active {
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom-color: var(--bg);
  margin-bottom: -1px;
}

.tab:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: -2px;
}

/* ---------- Panels ---------- */
.panels {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.panel {
  flex: 1;
  display: none;
  flex-direction: column;
  min-height: 0;
  overflow: auto;
  padding: 1.25rem;
}

.panel.active {
  display: flex;
}

.panel[hidden] {
  display: none !important;
}

/* ---------- Home ---------- */
.home-hero {
  max-width: 560px;
  margin: 2rem auto;
  text-align: center;
}

.home-hero h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.subtitle {
  color: var(--text-muted);
  margin-bottom: 1.75rem;
}

.url-form {
  margin-bottom: 2rem;
}

.input-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

input[type="url"],
input[type="text"] {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  padding: 12px 14px;
  min-width: 0;
  transition: border-color var(--transition);
}

input:focus {
  outline: none;
  border-color: var(--border-focus);
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  padding: 12px 20px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  white-space: nowrap;
}

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

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

.btn.icon {
  padding: 10px 12px;
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text-muted);
  min-width: 42px;
}

.btn.icon:hover {
  background: var(--bg-hover);
  color: var(--text);
}

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

.btn.danger:hover {
  background: rgba(239, 68, 68, 0.12);
}

.btn.danger.subtle {
  border-color: transparent;
  color: var(--text-muted);
}

.btn.danger.subtle:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.08);
}

.features {
  display: grid;
  gap: 1rem;
  text-align: left;
  margin-bottom: 2rem;
}

.feature {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.feature .icon {
  font-size: 1.25rem;
  line-height: 1.4;
}

.feature strong {
  display: block;
  margin-bottom: 2px;
}

.feature p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.disclaimer {
  color: var(--text-faint);
  font-size: 0.8rem;
  line-height: 1.45;
}

/* ---------- Browse ---------- */
#panel-browse {
  padding: 0;
}

.browse-toolbar {
  padding: 8px 12px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.url-form.compact .input-row {
  gap: 6px;
}

.url-form.compact input {
  padding: 10px 12px;
}

.url-form.compact .btn {
  padding: 10px 14px;
}

.browse-status {
  padding: 10px 16px;
  background: #1c1917;
  border-bottom: 1px solid var(--border);
  color: #fbbf24;
  font-size: 0.9rem;
}

.browse-status.error {
  background: #1c1212;
  color: #f87171;
}

.iframe-wrap {
  flex: 1;
  position: relative;
  min-height: 0;
  background: #000;
}

#proxy-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
  display: none;
}

#proxy-frame.visible {
  display: block;
}

.iframe-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  text-align: center;
  padding: 2rem;
}

.iframe-placeholder.hidden {
  display: none;
}

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

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

.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  transition: background var(--transition);
}

.history-list li:hover {
  background: var(--bg-hover);
}

.history-list a {
  flex: 1;
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.history-list a:hover {
  color: var(--primary-hover);
}

.history-list .time {
  color: var(--text-faint);
  font-size: 0.8rem;
  flex-shrink: 0;
}

.history-list .remove {
  appearance: none;
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 2px 6px;
  border-radius: 4px;
}

.history-list .remove:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

.empty-state {
  color: var(--text-faint);
  text-align: center;
  padding: 3rem 1rem;
}

/* ---------- Settings ---------- */
.settings-group {
  margin-bottom: 1.75rem;
  max-width: 480px;
}

.settings-group h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.75rem;
}

.setting {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 0.75rem;
}

.setting.checkbox {
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}

.setting.checkbox input {
  margin-top: 3px;
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.setting span {
  color: var(--text);
}

.hint {
  color: var(--text-faint);
  font-size: 0.85rem;
  margin-top: 4px;
}

.about-text {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  .home-hero {
    margin: 1rem auto;
  }

  .home-hero h1 {
    font-size: 1.4rem;
  }

  .input-row {
    flex-wrap: wrap;
  }

  .input-row input {
    flex: 1 1 100%;
  }

  .btn.primary {
    flex: 1;
  }

  .tabs {
    padding: 6px 8px 0;
  }

  .tab {
    padding: 8px 12px;
    font-size: 0.9rem;
  }

  .panel {
    padding: 1rem;
  }
}

/* Loading spinner (optional visual) */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-dot::after {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--text-muted);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}
