@tailwind base;
@tailwind components;
@tailwind utilities;

/* ============================================
   TRAFEXIA - Production UI Styles
   Based on HTTP Toolkit design language
   ============================================ */

:root {
  /* Color Palette */
  --color-bg-primary: #0d1117;
  --color-bg-secondary: #161b22;
  --color-bg-tertiary: #21262d;
  --color-bg-elevated: #30363d;
  
  --color-border: rgba(48, 54, 61, 0.8);
  --color-border-active: #58a6ff;
  
  --color-text-primary: #e6edf3;
  --color-text-secondary: #8b949e;
  --color-text-muted: #6e7681;
  
  --color-accent: #58a6ff;
  --color-accent-muted: rgba(88, 166, 255, 0.15);
  
  --color-success: #3fb950;
  --color-warning: #d29922;
  --color-error: #f85149;
  --color-info: #58a6ff;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
  
  /* Spacing */
  --header-height: 52px;
  --sidebar-width: 280px;

  --p-inputtext-padding-y: 0.5rem;
  --p-inputtext-padding-x: 0.75rem;
  --p-icon-size: 1rem;
  --p-form-field-padding-x: 0.75rem;
  --p-form-field-padding-y: 0.5rem;
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--color-bg-elevated);
  border-radius: 5px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
  background-clip: padding-box;
}

/* Base */
html, body, #app {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
  background-color: var(--color-bg-primary);
  color: var(--color-text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ============================================
   Layout Components
   ============================================ */

.app-header {
  height: var(--header-height);
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  -webkit-app-region: drag;
}

.app-header > * {
  -webkit-app-region: no-drag;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  color: var(--color-text-primary);
}

.app-logo-icon {
  width: 28px;
  height: 28px;
}

.app-content {
  height: calc(100% - var(--header-height));
  display: flex;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--color-bg-secondary);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  font-weight: 600;
  color: var(--color-text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.main-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.detail-panel {
  background: var(--color-bg-secondary);
  border-left: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ============================================
   Proxy Status Bar
   ============================================ */

.proxy-status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--color-bg-tertiary);
  border-radius: 6px;
}

.proxy-status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  animation: pulse-glow 2s infinite;
}

.proxy-status-indicator.running {
  background: var(--color-success);
  box-shadow: 0 0 0 3px rgba(63, 185, 80, 0.2);
}

.proxy-status-indicator.stopped {
  background: var(--color-text-muted);
  animation: none;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 3px rgba(63, 185, 80, 0.2); }
  50% { opacity: 0.8; box-shadow: 0 0 0 6px rgba(63, 185, 80, 0.1); }
}

.proxy-address {
  font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  font-size: 13px;
  color: var(--color-text-secondary);
  background: var(--color-bg-primary);
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid var(--color-border);
}

/* ============================================
   Buttons
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

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

.btn-primary:hover {
  background: #46c557;
}

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

.btn-danger:hover {
  background: #ff6b61;
}

.btn-secondary {
  background: var(--color-bg-tertiary);
  color: var(--color-text-primary);
  border-color: var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-bg-elevated);
}

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

.btn-ghost:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text-primary);
}

.btn-icon {
  padding: 8px;
  border-radius: 6px;
}

/* ============================================
   Request List Table
   ============================================ */

.request-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.request-table th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 12px;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--color-bg-tertiary);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 1;
}

.request-table tr {
  cursor: pointer;
  transition: background 0.1s;
}

.request-table tr:hover {
  background: var(--color-bg-tertiary);
}

.request-table tr.selected {
  background: var(--color-accent-muted);
}

.request-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.request-table .col-time {
  width: 80px;
  font-family: 'SF Mono', monospace;
  font-size: 12px;
  color: var(--color-text-muted);
}

.request-table .col-method {
  width: 70px;
}

.request-table .col-status {
  width: 60px;
}

.request-table .col-host {
  width: 200px;
  max-width: 200px;
}

.request-table .col-path {
  min-width: 200px;
  font-family: 'SF Mono', monospace;
  font-size: 12px;
  color: var(--color-text-secondary);
}

/* ============================================
   Method & Status Badges
   ============================================ */

.method-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.method-badge.GET    { background: rgba(63, 185, 80, 0.15); color: #3fb950; }
.method-badge.POST   { background: rgba(88, 166, 255, 0.15); color: #58a6ff; }
.method-badge.PUT    { background: rgba(210, 153, 34, 0.15); color: #d29922; }
.method-badge.PATCH  { background: rgba(163, 113, 247, 0.15); color: #a371f7; }
.method-badge.DELETE { background: rgba(248, 81, 73, 0.15); color: #f85149; }
.method-badge.OPTIONS { background: rgba(139, 148, 158, 0.15); color: #8b949e; }
.method-badge.HEAD   { background: rgba(139, 148, 158, 0.15); color: #8b949e; }

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  font-family: 'SF Mono', monospace;
}

.status-badge.status-2xx { background: rgba(63, 185, 80, 0.15); color: #3fb950; }
.status-badge.status-3xx { background: rgba(88, 166, 255, 0.15); color: #58a6ff; }
.status-badge.status-4xx { background: rgba(210, 153, 34, 0.15); color: #d29922; }
.status-badge.status-5xx { background: rgba(248, 81, 73, 0.15); color: #f85149; }
.status-badge.status-0   { background: rgba(139, 148, 158, 0.15); color: #8b949e; }

/* ============================================
   Detail Panel
   ============================================ */

.detail-header {
  padding: 12px 16px;
  background: var(--color-bg-tertiary);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.detail-url {
  flex: 1;
  font-family: 'SF Mono', monospace;
  font-size: 13px;
  color: var(--color-text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-tabs {
  display: flex;
  background: var(--color-bg-tertiary);
  border-bottom: 1px solid var(--color-border);
}

.detail-tab {
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
}

.detail-tab:hover {
  color: var(--color-text-primary);
}

.detail-tab.active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

.detail-content {
  flex: 1;
  overflow: auto;
  padding: 16px;
}

/* ============================================
   Code Blocks
   ============================================ */

.code-block {
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 16px;
  font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--color-text-primary);
}

.code-block.compact {
  padding: 8px 12px;
  font-size: 12px;
}

/* Headers Table */
.headers-table {
  width: 100%;
  font-size: 13px;
}

.headers-table tr {
  border-bottom: 1px solid var(--color-border);
}

.headers-table td {
  padding: 8px 0;
  vertical-align: top;
}

.headers-table .header-name {
  width: 200px;
  font-weight: 600;
  color: var(--color-accent);
  font-family: 'SF Mono', monospace;
  font-size: 12px;
}

.headers-table .header-value {
  color: var(--color-text-secondary);
  font-family: 'SF Mono', monospace;
  font-size: 12px;
  word-break: break-all;
}

/* ============================================
   Filters
   ============================================ */

.filter-section {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
}

.filter-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.filter-input {
  width: 100%;
  padding: 8px 12px;
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-text-primary);
  font-size: 13px;
}

.filter-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px var(--color-accent-muted);
}

.filter-input::placeholder {
  color: var(--color-text-muted);
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  font-size: 12px;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  margin: 2px;
}

.filter-chip:hover {
  background: var(--color-bg-elevated);
}

.filter-chip.active {
  background: var(--color-accent-muted);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* ============================================
   Empty State
   ============================================ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 40px;
  text-align: center;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  opacity: 0.3;
  margin-bottom: 16px;
}

.empty-state-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 8px;
}

.empty-state-text {
  font-size: 14px;
  color: var(--color-text-secondary);
  max-width: 300px;
}

/* ============================================
   PrimeVue Overrides
   ============================================ */

.p-splitter {
  background: transparent;
  border: none;
}

.p-splitter-gutter {
  background: var(--color-border);
}

.p-splitter-gutter:hover {
  background: var(--color-accent);
}

.p-datatable {
  font-size: 13px;
}

.p-datatable .p-datatable-thead > tr > th {
  background: var(--color-bg-tertiary);
  border-color: var(--color-border);
  color: var(--color-text-secondary);
  font-weight: 600;
  font-size: 12px;
  padding: 10px 12px;
}

.p-datatable .p-datatable-tbody > tr {
  background: transparent;
  transition: background 0.1s;
}

.p-datatable .p-datatable-tbody > tr:hover {
  background: var(--color-bg-tertiary);
}

.p-datatable .p-datatable-tbody > tr > td {
  border-color: var(--color-border);
  padding: 8px 12px;
}

.p-datatable .p-datatable-tbody > tr.p-highlight {
  background: var(--color-accent-muted);
}

.p-tabview .p-tabview-nav {
  background: var(--color-bg-tertiary);
  border-color: var(--color-border);
}

.p-tabview .p-tabview-nav li .p-tabview-nav-link {
  background: transparent;
  border-color: transparent;
  color: var(--color-text-secondary);
  padding: 12px 20px;
  font-weight: 500;
}

.p-tabview .p-tabview-nav li.p-highlight .p-tabview-nav-link {
  background: transparent;
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.p-tabview .p-tabview-panels {
  background: transparent;
  padding: 0;
}

.p-button {
  border-radius: 6px;
  font-weight: 500;
}

.p-inputtext {
  background: var(--color-bg-primary);
  border-color: var(--color-border);
  border-radius: 6px;
  color: var(--color-text-primary);
  padding-block: var(--p-inputtext-padding-y);
  padding-inline: var(--p-inputtext-padding-x);
}

.p-inputtext:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px var(--color-accent-muted);
}

.p-dialog {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
}

.p-dialog .p-dialog-header {
  background: transparent;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-primary);
}

.p-dialog .p-dialog-content {
  background: transparent;
  color: var(--color-text-primary);
}

.p-toast .p-toast-message {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 8px;
}

/* Syntax highlighting */
.hljs {
  background: transparent !important;
  padding: 0 !important;
}

li.p-column-filter-row-item {
	padding: 0.5rem 0.75rem;
}

.p-component {
	font-size: inherit;
}

.p-hidden-space {
	display: none;
}