:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #141414;
  --bg-tertiary: #1e1e1e;
  --text-primary: #f0f0f0;
  --text-secondary: #888;
  --accent: #00d4ff;
  --accent-hover: #00b8e6;
  --success: #00ff88;
  --error: #ff4466;
  --warning: #ffaa00;
  --border: #2a2a2a;
}

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

html {
  overflow-x: hidden;
}

body {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  padding: 2rem;
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
}

h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  background: linear-gradient(90deg, var(--accent), #ff00aa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-secondary);
  margin-bottom: 2rem;
  font-size: 0.9rem;
}

.back-link {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

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

.control-panel {
  background: var(--bg-secondary);
  padding: 2rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-bottom: 2rem;
}

.manual-test-section {
  margin-bottom: 1.5rem;
}

input[type="text"]:focus {
  border-color: var(--accent);
}

input[type="text"]::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

/* Custom Category Dropdown Styles */
.custom-dropdown-wrapper {
  position: relative;
}

.category-input:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

.category-input:focus+.dropdown-icon {
  color: var(--accent);
  transform: translateY(-50%) rotate(180deg);
}

.category-dropdown {
  animation: slideDown 0.2s ease-out;
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.category-dropdown::-webkit-scrollbar {
  width: 8px;
}

.category-dropdown::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 8px;
}

.category-dropdown::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 8px;
  transition: background 0.2s;
}

.category-dropdown::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

.category-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  color: var(--text-primary);
  font-family: monospace;
  font-size: 0.9rem;
  transition: all 0.15s ease;
  border-left: 3px solid transparent;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.category-item:hover {
  background: var(--bg-tertiary);
  border-left-color: var(--accent);
  padding-left: 1.25rem;
}

.category-item.selected {
  background: rgba(0, 212, 255, 0.15);
  border-left-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.category-item .category-icon {
  font-size: 1rem;
  opacity: 0.7;
}

.category-item:hover .category-icon {
  opacity: 1;
}

.category-empty {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.button-group {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

button {
  padding: 1rem 2rem;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 600;
  background: var(--accent);
  color: var(--bg-primary);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  flex: 1;
}

button:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

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

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.stat-card {
  background: var(--bg-tertiary);
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  letter-spacing: 1px;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
}

.stat-value.success {
  color: var(--success);
}

.stat-value.error {
  color: var(--error);
}

.stat-value.pending {
  color: var(--warning);
}

.stat-value.total {
  color: var(--accent);
}

.progress-section {
  background: var(--bg-secondary);
  padding: 2rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-bottom: 2rem;
  display: none;
}

.progress-section.visible {
  display: block;
}

.progress-bar-container {
  background: var(--bg-tertiary);
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #ff00aa);
  width: 0%;
  transition: width 0.3s ease;
}

.progress-text {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.report-link-section {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--bg-tertiary);
  border-radius: 8px;
  border: 1px solid var(--border);
  text-align: center;
  display: none;
}

.report-link-section.visible {
  display: block;
}

.report-link-section a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
}

.report-link-section a:hover {
  text-decoration: underline;
}

.logs-container {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  max-height: 200px;
  overflow-y: auto;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 1rem;
  font-family: 'Courier New', monospace;
}

.log-entry {
  padding: 0.25rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.log-entry:last-child {
  border-bottom: none;
}

.log-entry.success {
  color: var(--success);
}

.log-entry.error {
  color: var(--error);
}

.results-section {
  background: var(--bg-secondary);
  padding: 2rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  display: block !important;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

h2 {
  font-size: 1.5rem;
  color: var(--text-primary);
}

.filter-buttons {
  display: flex;
  gap: 0.5rem;
}

.filter-btn {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
}

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

.filter-btn.active {
  background: var(--accent);
  color: var(--bg-primary);
  border-color: var(--accent);
}

.results-grid {
  display: grid;
  gap: 1rem;
}

.result-card {
  background: var(--bg-tertiary);
  border-radius: 8px;
  border: 1px solid var(--border);
  overflow: hidden;
  transition: all 0.2s;
}

.result-card:hover {
  border-color: var(--accent);
}

.result-card.failed {
  border-color: var(--error);
}

.result-card.success {
  border-color: var(--success);
}

.result-card.retrying {
  border-color: var(--warning);
  opacity: 0.7;
}

.result-header {
  padding: 1rem;
  background: var(--bg-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.webhook-info {
  flex: 1;
}

.webhook-title {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.webhook-id {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-family: monospace;
}

.status-badge {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.status-badge.success {
  background: rgba(0, 255, 136, 0.15);
  color: var(--success);
}

.status-badge.failed {
  background: rgba(255, 68, 102, 0.15);
  color: var(--error);
}

.status-badge.retrying {
  background: rgba(255, 170, 0, 0.15);
  color: var(--warning);
}

.retry-btn {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  background: var(--accent);
  color: var(--bg-primary);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.retry-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

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

.retry-status {
  margin-top: 1rem;
  padding: 0.75rem;
  background: var(--bg-primary);
  border-radius: 6px;
  font-size: 0.85rem;
  text-align: center;
}

.retry-status.loading {
  color: var(--warning);
}

.retry-status.success {
  color: var(--success);
}

.retry-status.error {
  color: var(--error);
}

.error-group {
  margin-bottom: 1.5rem;
  background: var(--bg-tertiary);
  border-radius: 8px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.error-group-header {
  padding: 1rem 1.5rem;
  background: var(--bg-card);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.2s;
  border-left: 4px solid var(--error);
}

.error-group-header:hover {
  background: var(--bg-secondary);
}

.error-icon {
  font-size: 1.2rem;
  margin-right: 0.5rem;
}

.error-message {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.95rem;
}

.error-count {
  padding: 0.25rem 0.75rem;
  background: rgba(255, 68, 102, 0.15);
  color: var(--error);
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
}

.expand-icon {
  color: var(--text-secondary);
  font-size: 0.8rem;
  transition: transform 0.2s;
}

.error-group.expanded .expand-icon {
  transform: rotate(180deg);
}

.error-group-content {
  display: none;
  padding: 1rem;
  background: var(--bg-primary);
}

.error-group.expanded .error-group-content {
  display: block;
}

.error-group .result-card {
  margin-bottom: 1rem;
}

.error-group .result-card:last-child {
  margin-bottom: 0;
}

.group-toggle-btn {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 600;
}

.group-toggle-btn:hover {
  background: var(--border);
}

.group-toggle-btn.active {
  background: var(--accent);
  color: var(--bg-primary);
  border-color: var(--accent);
}

.history-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--accent);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8), 0 0 0 1000px rgba(0, 0, 0, 0.5);
  min-width: 450px;
  max-height: 500px;
  overflow: hidden;
  z-index: 9999;
  display: none;
}

.history-dropdown.visible {
  display: block;
  animation: slideDown 0.2s ease;
}

.history-dropdown-header {
  padding: 1rem 1.5rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.history-dropdown-content {
  max-height: 400px;
  overflow-y: auto;
}

.history-loading {
  padding: 2rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.history-item {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-item:last-child {
  border-bottom: none;
}

.history-item:hover {
  background: var(--bg-secondary);
}

.history-item-info {
  flex: 1;
}

.history-item-name {
  font-size: 0.85rem;
  color: var(--accent);
  font-family: monospace;
  margin-bottom: 0.25rem;
}

.history-item-date {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.history-item-size {
  font-size: 0.75rem;
  color: var(--text-secondary);
  padding: 0.25rem 0.5rem;
  background: var(--bg-tertiary);
  border-radius: 4px;
}

.history-empty {
  padding: 2rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.result-content {
  padding: 1rem;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
}

.media-item {
  background: var(--bg-primary);
  border-radius: 8px;
  padding: 1rem;
  border: 1px solid var(--border);
}

.media-type {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  background: rgba(0, 212, 255, 0.15);
  color: var(--accent);
  border-radius: 4px;
  margin-bottom: 0.75rem;
}

.media-preview img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

.media-preview video {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  background: var(--bg-primary);
}

.media-link {
  font-size: 0.7rem;
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
  display: block;
}

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

.error-message {
  padding: 1rem;
  background: rgba(255, 68, 102, 0.1);
  border: 1px solid var(--error);
  border-radius: 6px;
  color: var(--error);
  font-size: 0.875rem;
}

.no-results {
  text-align: center;
  padding: 3rem;
  color: var(--text-secondary);
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 0.5rem;
}

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

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
  body {
    padding: 1rem;
  }

  .container {
    max-width: 100%;
  }

  h1 {
    font-size: 1.75rem;
    margin-bottom: 1rem;
  }

  .header {
    padding: 1.5rem 1rem;
  }

  .input-section {
    padding: 1rem;
    margin-bottom: 1rem;
  }

  .input-group {
    flex-direction: column;
    gap: 0.75rem;
  }

  .input-group input {
    width: 100%;
  }

  .manual-test-row {
    flex-direction: column !important;
    gap: 0.75rem !important;
  }

  .manual-input {
    width: 100% !important;
    min-width: 100% !important;
    flex: none !important;
  }

  .test-selected-btn {
    width: 100%;
    padding: 0.75rem 1rem !important;
  }

  .control-buttons {
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch;
  }

  .control-buttons button {
    width: 100%;
    justify-content: center;
  }

  .button-group {
    flex-direction: column;
    gap: 0.75rem;
  }

  .button-group button {
    width: 100%;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
  }

  .stat-card {
    padding: 1rem;
    min-height: auto;
  }

  .stat-value {
    font-size: 1.75rem;
    margin-bottom: 0.25rem;
  }

  .stat-label {
    font-size: 0.75rem;
    letter-spacing: 0.5px;
  }

  .results-section {
    padding: 1rem;
  }

  .results-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
  }

  .results-header h2 {
    font-size: 1.25rem;
    width: 100%;
  }

  .results-title {
    font-size: 1.25rem;
  }

  .filter-buttons {
    width: 100%;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: stretch;
  }

  .filter-btn {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: calc(50% - 0.25rem);
    justify-content: center;
    padding: 0.65rem 0.75rem;
    font-size: 0.85rem;
  }

  .no-results {
    padding: 2rem 1rem;
    font-size: 0.9rem;
  }

  .results-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .result-card {
    margin-bottom: 1rem;
  }

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

  .card-title {
    font-size: 1rem;
  }

  .card-badges {
    flex-wrap: wrap;
    width: 100%;
  }

  .result-content {
    padding: 1rem;
  }

  .media-grid {
    grid-template-columns: 1fr;
  }

  .progress-section {
    padding: 1rem;
    border-radius: 8px;
  }

  .progress-bar-container {
    margin-bottom: 0.75rem;
  }

  .progress-text {
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
    word-break: break-word;
  }

  .logs-container {
    font-size: 0.7rem;
    max-height: 200px;
    line-height: 1.4;
  }

  .history-dropdown {
    min-width: 95vw;
    max-width: 95vw;
    right: auto;
    left: 50%;
    transform: translateX(-50%);
  }

  /* Touch-friendly tap targets (minimum 44x44px) */
  button {
    min-height: 44px;
    touch-action: manipulation;
  }

  .retry-btn,
  .filter-btn {
    min-height: 44px;
  }

  .report-link-section {
    font-size: 0.85rem;
  }

  #shareReportBtn {
    width: 100%;
    margin-top: 0.75rem;
  }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
  body {
    padding: 0.5rem;
  }

  h1 {
    font-size: 1.5rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .stat-card {
    padding: 0.85rem;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .stat-value {
    font-size: 1.75rem;
    order: 2;
  }

  .stat-label {
    font-size: 0.8rem;
    order: 1;
    text-align: left;
  }

  .filter-btn {
    flex: 1 1 100%;
    min-width: 100%;
    max-width: 100%;
    font-size: 0.85rem;
  }

  .results-section {
    padding: 0.75rem;
  }

  .results-header {
    gap: 0.75rem;
    margin-bottom: 1rem;
  }

  .results-header h2 {
    font-size: 1.1rem;
  }

  .results-title {
    font-size: 1.1rem;
  }

  .no-results {
    padding: 1.5rem 0.75rem;
    font-size: 0.85rem;
    line-height: 1.5;
  }

  .manual-test-row {
    gap: 0.5rem !important;
  }

  .manual-input {
    font-size: 0.85rem !important;
    padding: 0.65rem 0.85rem !important;
  }

  .test-selected-btn {
    font-size: 0.85rem;
    padding: 0.65rem 0.85rem !important;
  }

  .card-badges {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .stat-card {
    padding: 0.75rem;
  }

  .stat-value {
    font-size: 1.5rem;
  }

  button {
    padding: 0.65rem 1rem;
    font-size: 0.9rem;
  }

  .input-section {
    padding: 0.75rem;
  }

  .progress-section {
    padding: 0.75rem;
    border-radius: 8px;
  }

  .progress-text {
    font-size: 0.8rem;
  }

  .result-card {
    border-radius: 8px;
  }

  .card-header {
    padding: 0.75rem;
  }

  .card-title {
    font-size: 0.9rem;
    word-break: break-word;
  }

  .card-subtitle {
    font-size: 0.75rem;
  }

  .media-preview img,
  .media-preview video {
    max-height: 150px;
  }

  .url-text {
    font-size: 0.65rem;
    word-break: break-all;
  }

  input[type="text"] {
    font-size: 16px;
    /* Prevents iOS zoom on focus */
  }

  textarea {
    font-size: 16px;
    /* Prevents iOS zoom on focus */
  }

  .logs-container {
    font-size: 0.65rem;
    padding: 0.75rem;
  }

  .error-message {
    padding: 1rem;
    font-size: 0.85rem;
    word-break: break-word;
  }

  .retry-status {
    font-size: 0.85rem;
    padding: 1rem;
  }

  #shareReportBtn {
    width: 100%;
    padding: 0.75rem;
    margin-top: 0.5rem;
  }

  .report-link-section {
    padding: 1rem;
    text-align: center;
  }

  .report-link-section p {
    margin: 0.5rem 0;
    word-break: break-all;
  }
}
