/* === Variables === */
:root {
  --bg-primary: #1a1a2e;
  --bg-surface: #16213e;
  --bg-card: #0f3460;
  --bg-input: #1a1a3e;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0b0;
  --text-muted: #6a6a7a;
  --accent: #00bcd4;
  --accent-hover: #00acc1;
  --accent-dim: rgba(0, 188, 212, 0.15);
  --danger: #ef5350;
  --danger-hover: #e53935;
  --success: #66bb6a;
  --border: #2a2a4a;
  --border-light: #3a3a5a;
  --sidebar-width: 250px;
  --sidebar-collapsed: 64px;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --transition: 0.2s ease;
}

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

html {
  font-size: 14px;
}

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

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  color: var(--accent-hover);
}

/* === Layout === */
body.has-sidebar {
  display: flex;
}

.content {
  flex: 1;
  padding: 2rem;
  margin-left: var(--sidebar-width);
  transition: margin-left var(--transition);
  max-width: 1200px;
}

.content--full {
  margin-left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  max-width: 100%;
}

body.sidebar-collapsed .content {
  margin-left: var(--sidebar-collapsed);
}

/* === Sidebar === */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width var(--transition);
  z-index: 100;
  overflow: hidden;
}

body.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed);
}

.sidebar__header {
  display: flex;
  align-items: center;
  padding: 1rem;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border);
  min-height: 60px;
  flex-wrap: nowrap;
  overflow: visible;
}

body.sidebar-collapsed .sidebar__header {
  justify-content: center;
  padding: 0.75rem;
  gap: 0;
}

.sidebar__logo {
  background: var(--accent);
  color: var(--bg-primary);
  font-weight: 700;
  font-size: 1rem;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar__title {
  font-weight: 500;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
}

body.sidebar-collapsed .sidebar__title,
body.sidebar-collapsed .sidebar__label {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

body.sidebar-collapsed .sidebar__logo {
  display: none;
}

.sidebar__toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  margin-left: auto;
  flex-shrink: 0;
}

body.sidebar-collapsed .sidebar__toggle {
  margin-left: 0;
}
.sidebar__toggle:hover {
  color: var(--accent);
}

.sidebar__user {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__nav {
  flex: 1;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all var(--transition);
  white-space: nowrap;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.95rem;
  font-family: inherit;
  width: 100%;
  text-align: left;
}
.sidebar__link:hover {
  background: var(--accent-dim);
  color: var(--accent);
}
.sidebar__link--active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 500;
}

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

.sidebar__footer {
  padding: 0.5rem;
  border-top: 1px solid var(--border);
}

.sidebar__logout {
  color: var(--danger) !important;
}
.sidebar__logout:hover {
  background: rgba(239, 83, 80, 0.15) !important;
}

/* === Cards === */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.card--highlight {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--bg-surface), var(--bg-card));
}

.card--form {
  margin-bottom: 1.5rem;
}

.card--url {
  margin-bottom: 1.5rem;
}

.card h2, .card h3 {
  margin-bottom: 0.75rem;
  font-weight: 500;
}

/* === Page Header === */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 500;
}

.back-btn {
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
}
.back-btn svg {
  vertical-align: middle;
  margin-right: 0.25rem;
}

.page-header__sub {
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

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

.btn--accent {
  background: transparent;
  border-color: var(--accent);
  color: var(--accent);
}
.btn--accent:hover {
  background: var(--accent-dim);
  color: var(--accent);
}

.btn--danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
.btn--danger:hover {
  background: rgba(239, 83, 80, 0.15);
}

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn--ghost:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

.btn--sm {
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
}

.btn--block {
  width: 100%;
  margin-top: 1rem;
}

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

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

.form-input {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color var(--transition);
}
.form-input:focus {
  outline: none;
  border-color: var(--accent);
}

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

.form-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-group--inline {
  flex: 0 0 140px;
}

.form-group--fill {
  flex: 1;
}

.form-textarea {
  resize: vertical;
  font-family: 'Roboto Mono', monospace;
  font-size: 0.85rem;
  min-height: 60px;
}

.text-muted {
  color: var(--text-muted);
  font-style: italic;
}

/* === Response Config === */
.card--response-config {
  margin-bottom: 1.5rem;
}

.response-config__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.response-config__header h3 {
  font-size: 1rem;
  font-weight: 500;
}

.response-config__display {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.response-config__item {
  display: flex;
  gap: 1rem;
  align-items: baseline;
}

.response-config__label {
  color: var(--text-secondary);
  min-width: 120px;
  font-size: 0.85rem;
}

.response-config__value {
  font-size: 0.9rem;
}

.json-display--sm {
  max-height: 120px;
  font-size: 0.8rem;
}

/* === Alerts === */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert--danger {
  background: rgba(239, 83, 80, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 83, 80, 0.3);
}

.alert--success {
  background: rgba(102, 187, 106, 0.15);
  color: var(--success);
  border: 1px solid rgba(102, 187, 106, 0.3);
}

/* === Table === */
.table-wrapper {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.table th,
.table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table th {
  background: var(--bg-card);
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

.table tr:hover td {
  background: rgba(0, 188, 212, 0.05);
}

/* === Badge === */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-dim);
  color: var(--accent);
  padding: 0.15rem 0.6rem;
  border-radius: 100px;
  font-size: 0.8rem;
  font-weight: 500;
}

/* === Code === */
.code-inline {
  background: var(--bg-card);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  font-family: 'Roboto Mono', monospace;
  font-size: 0.85rem;
  color: var(--accent);
}

/* === Token Display === */
.token-display {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin: 0.75rem 0;
}

.token-display code {
  font-family: 'Roboto Mono', monospace;
  font-size: 1.1rem;
  color: var(--accent);
  letter-spacing: 0.1em;
  flex: 1;
  user-select: all;
}

/* === URL Display === */
.url-display {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin: 0.5rem 0;
}

.url-display code {
  font-family: 'Roboto Mono', monospace;
  font-size: 0.9rem;
  color: var(--text-primary);
  flex: 1;
  word-break: break-all;
  user-select: all;
}

.url-display__hint {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 0.25rem;
}

/* === Webhook List === */
.webhook-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.webhook-list-header h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}

.webhook-list-header__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn--disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.refresh-icon.spin {
  animation: spin 0.8s linear infinite;
}

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

.webhook-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  overflow: hidden;
}

.webhook-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background var(--transition);
}
.webhook-card__header:hover {
  background: rgba(0, 188, 212, 0.05);
}

.webhook-card__meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.webhook-card__host {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.webhook-card__time {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.webhook-card__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.webhook-card__chevron {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  transition: transform var(--transition);
}

.webhook-card.open .webhook-card__chevron {
  transform: rotate(180deg);
}

.webhook-card__body {
  border-top: 1px solid var(--border);
  padding: 1rem;
}

/* === Method Badges === */
.method-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  font-family: 'Roboto Mono', monospace;
  letter-spacing: 0.05em;
}

.method-badge--post { background: rgba(76, 175, 80, 0.2); color: #66bb6a; }
.method-badge--get { background: rgba(33, 150, 243, 0.2); color: #42a5f5; }
.method-badge--put { background: rgba(255, 152, 0, 0.2); color: #ffa726; }
.method-badge--patch { background: rgba(156, 39, 176, 0.2); color: #ab47bc; }
.method-badge--delete { background: rgba(239, 83, 80, 0.2); color: #ef5350; }

/* === JSON Display === */
.json-display {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.8rem;
  line-height: 1.5;
  max-height: 400px;
  overflow-y: auto;
}

.json-display code {
  font-family: 'Roboto Mono', monospace;
  color: var(--text-primary);
  white-space: pre;
}

.webhook-data__section {
  margin-bottom: 1rem;
}

.webhook-data__section:last-child {
  margin-bottom: 0;
}

.webhook-data__section h4 {
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* === Info Grid === */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.info-item__label {
  display: block;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 0.25rem;
}

.info-item__value {
  font-size: 0.95rem;
}

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-secondary);
}

.empty-state__icon {
  width: 64px;
  height: 64px;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.empty-state h3 {
  font-weight: 500;
  margin-bottom: 0.5rem;
}

/* === Error Page === */
.error-page {
  text-align: center;
  padding: 3rem;
}

.error-page h1 {
  font-size: 2rem;
  margin-bottom: 1rem;
}

.error-page p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

/* === Login Page === */
.login-page {
  width: 100%;
  max-width: 700px;
  padding: 2rem;
}

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

.login-hero__title {
  font-size: 2.25rem;
  font-weight: 300;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.login-hero__subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
}

.login-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.login-card {
  padding: 1.5rem;
}

.login-card h2 {
  font-size: 1.25rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

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

/* === Pagination === */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  margin-top: 1.5rem;
}

/* === Link === */
.link {
  color: var(--accent);
  font-weight: 500;
}
.link:hover {
  text-decoration: underline;
}

/* === Responsive === */
@media (max-width: 768px) {
  .sidebar {
    width: var(--sidebar-collapsed);
  }
  .sidebar__title,
  .sidebar__label {
    opacity: 0;
    width: 0;
    overflow: hidden;
  }
  .content {
    margin-left: var(--sidebar-collapsed);
  }
  .login-cards {
    grid-template-columns: 1fr;
  }
  .page-header {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .content {
    padding: 1rem;
  }
  .webhook-card__meta {
    flex-wrap: wrap;
  }
}
