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

:root {
    --bg: #0a0a0a;
    --surface: #111111;
    --surface-2: #161616;
    --border: #1f1f1f;
    --border-light: #2a2a2a;
    --text: #fafafa;
    --text-muted: #737373;
    --text-dim: #525252;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --critical: #dc2626;
    /* Aliases for pages that use alternate naming */
    --bg-primary: var(--bg);
    --bg-secondary: var(--surface);
    --bg-tertiary: var(--surface-2);
    --bg-hover: var(--surface-2);
    --text-primary: var(--text);
    --text-secondary: var(--text-muted);
    --border-color: var(--border);
    --card-bg: var(--surface);
    --primary: var(--accent);
    --primary-color: var(--accent);
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    --nav-bg: rgba(10, 10, 10, 0.85);
}

/* Light theme overrides */
[data-theme="light"] {
    --bg: #f8f9fa;
    --surface: #ffffff;
    --surface-2: #f0f0f0;
    --border: #e0e0e0;
    --border-light: #d0d0d0;
    --text: #1a1a1a;
    --text-muted: #666666;
    --text-dim: #999999;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --success: #16a34a;
    --warning: #d97706;
    --error: #dc2626;
    --critical: #b91c1c;
    --nav-bg: rgba(248, 249, 250, 0.9);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

.container-narrow {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Theme toggle button */
.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px 8px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    color: var(--text-muted);
    transition: all 0.15s;
    margin-right: 8px;
}

.theme-toggle:hover {
    border-color: var(--border-light);
    color: var(--text);
}

/* Bookmark / star button */
.bookmark-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 2px 4px;
    opacity: 0.4;
    transition: all 0.15s;
    line-height: 1;
}

.bookmark-btn:hover,
.bookmark-btn.active {
    opacity: 1;
}

.bookmark-btn.active {
    color: var(--warning);
}

/* Connection / reconnection indicator */
.conn-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-dim);
    padding: 4px 10px;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
}

.conn-indicator .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
}

.conn-indicator .dot.disconnected {
    background: var(--error);
    animation: pulse-dot 1.5s infinite;
}

.conn-indicator .dot.reconnecting {
    background: var(--warning);
    animation: pulse-dot 0.8s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Source filter dropdown */
.source-filter-select {
    padding: 6px 12px;
    font-size: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23737373' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 24px;
}

/* Expiration badge */
.badge-expiry {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
    font-size: 11px;
}

/* Navigation */
nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 12px 0;
    background: var(--nav-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

nav .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-wrapper {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.logo {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text);
}

.logo span {
    color: var(--text-muted);
    font-weight: 400;
    margin-left: 8px;
    font-size: 12px;
}

.made-with {
    font-size: 10px;
    color: var(--text-dim);
    letter-spacing: 0.02em;
}

.nav-links {
    display: flex;
    gap: 8px;
    list-style: none;
}

.nav-links a {
    color: var(--text-muted);
    font-size: 13px;
    padding: 6px 12px;
    border-radius: 6px;
    transition: all 0.15s;
}

.nav-links a:hover {
    color: var(--text);
    background: var(--surface);
}

.nav-links a.active {
    color: var(--text);
    background: var(--surface);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

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

.btn-primary:hover {
    opacity: 0.9;
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--border-light);
    background: var(--surface-2);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

/* Page Layout */
.page {
    padding-top: 60px;
    min-height: 100vh;
}

.page-header {
    padding: 32px 0 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}

.page-header p {
    color: var(--text-muted);
    font-size: 14px;
}

/* Stats Bar */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 24px;
}

.stats-bar .stat {
    background: var(--surface);
    padding: 16px 20px;
    text-align: center;
}

.stats-bar .stat-value {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.stats-bar .stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

/* Paste List */
.paste-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.paste-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 16px;
    align-items: center;
    padding: 14px 18px;
    background: var(--surface);
    transition: background 0.15s;
}

.paste-item:hover {
    background: var(--surface-2);
}

.paste-info {
    min-width: 0;
}

.paste-title {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.paste-meta {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

.paste-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.paste-badges {
    display: flex;
    gap: 6px;
}

.badge {
    padding: 3px 8px;
    font-size: 10px;
    font-weight: 500;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-sensitive {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.badge-source {
    background: var(--bg);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.badge-critical {
    background: rgba(220, 38, 38, 0.15);
    color: var(--critical);
}

.badge-high {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.badge-moderate {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.badge-low {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

/* High-value alert item highlighting */
.paste-item.high-value-item {
    border-left: 3px solid var(--critical);
    background: linear-gradient(90deg, rgba(220, 38, 38, 0.08), transparent);
}

.paste-item.high-value-item:hover {
    background: linear-gradient(90deg, rgba(220, 38, 38, 0.15), var(--surface-2));
}

.paste-time {
    font-size: 12px;
    color: var(--text-dim);
    white-space: nowrap;
}

/* Search */
.search-box {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

.search-input {
    flex: 1;
    padding: 10px 14px;
    font-size: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    outline: none;
    transition: border-color 0.15s;
}

.search-input:focus {
    border-color: var(--border-light);
}

.search-input::placeholder {
    color: var(--text-dim);
}

/* Filters */
.filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.filter-btn {
    padding: 6px 12px;
    font-size: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.filter-btn:hover {
    color: var(--text);
    border-color: var(--border-light);
}

.filter-btn.active {
    color: var(--text);
    background: var(--surface-2);
    border-color: var(--border-light);
}

/* Paste Detail */
.paste-detail {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.paste-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.paste-detail-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.paste-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 13px;
    color: var(--text-muted);
}

.paste-detail-actions {
    display: flex;
    gap: 8px;
}

.paste-content {
    padding: 20px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--bg);
}

.paste-patterns {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.paste-patterns h3 {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

.pattern-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pattern-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    font-size: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
}

/* Upload Form */
.upload-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    outline: none;
    transition: border-color 0.15s;
}

.form-input:focus {
    border-color: var(--border-light);
}

.form-textarea {
    min-height: 300px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.6;
    resize: vertical;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23737373' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-hint {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 6px;
}

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

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-muted);
}

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

.empty-state p {
    font-size: 14px;
    margin-bottom: 20px;
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-muted);
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--text);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 10px;
}

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

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 24px;
}

.pagination button {
    padding: 8px 14px;
    font-size: 13px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.pagination button:hover:not(:disabled) {
    color: var(--text);
    border-color: var(--border-light);
}

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

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s;
    z-index: 1000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

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

.toast.error {
    border-color: var(--error);
}

/* Footer */
footer {
    padding: 32px 0;
    border-top: 1px solid var(--border);
    margin-top: 48px;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--text-muted);
}

.footer-links {
    display: flex;
    gap: 20px;
    list-style: none;
}

.footer-links a:hover {
    color: var(--text);
}

/* =============================================================================
   HTMX & ALPINE.JS ENHANCEMENTS
   ============================================================================= */

/* Skeleton Loaders */
.skeleton {
    background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 6px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-paste {
    height: 72px;
    margin-bottom: 8px;
    border-radius: 8px;
}

.skeleton-stat {
    min-height: 52px;
}

/* Loading indicator for infinite scroll */
.load-more-trigger {
    padding: 24px;
    text-align: center;
}

.loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 13px;
}

/* HTMX loading states */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline-flex;
}

/* Severity-based paste styling */
.paste-item.severity-critical {
    border-left: 4px solid var(--critical);
    background: linear-gradient(90deg, rgba(220, 38, 38, 0.08) 0%, transparent 50%);
}

.paste-item.severity-critical:hover {
    background: linear-gradient(90deg, rgba(220, 38, 38, 0.12) 0%, var(--surface-2) 50%);
}

.paste-item.severity-high {
    border-left: 4px solid var(--warning);
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.06) 0%, transparent 50%);
}

.paste-item.severity-high:hover {
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.1) 0%, var(--surface-2) 50%);
}

.paste-item.severity-medium {
    border-left: 4px solid var(--accent);
}

/* Search results count */
.results-count {
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}

/* Error state */
.error-state {
    padding: 32px;
    text-align: center;
    color: var(--error);
    font-size: 14px;
}

/* Alpine.js transition classes */
.transition {
    transition-property: all;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

/* Mobile Hamburger Menu */
.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    padding: 8px;
    border: none;
    background: none;
    z-index: 110;
}

.hamburger span {
    width: 22px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: all 0.3s;
}

.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* Finding type filter tabs */
.feed-filters {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.feed-filter-btn {
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 500;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.feed-filter-btn:hover {
    color: var(--text);
    border-color: var(--border-light);
}

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

.feed-filter-btn .count {
    margin-left: 4px;
    opacity: 0.6;
    font-size: 11px;
}

/* Character counter */
.char-counter {
    font-size: 12px;
    color: var(--text-dim);
    text-align: right;
    margin-top: 6px;
}

.char-counter.warning {
    color: var(--warning);
}

.char-counter.danger {
    color: var(--error);
}

/* Keyboard shortcut hints */
.kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    padding: 2px 6px;
    font-size: 11px;
    font-family: var(--font-mono);
    background: var(--surface-2);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    color: var(--text-dim);
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }
    
    .stats-bar {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .paste-item {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .paste-badges {
        order: -1;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .footer-content {
        flex-direction: column;
        gap: 16px;
    }
    
    .hamburger {
        display: flex;
    }

    .nav-links {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(10, 10, 10, 0.98);
        backdrop-filter: blur(12px);
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 12px;
        z-index: 105;
    }

    .nav-links.open {
        display: flex;
    }

    .nav-links a {
        font-size: 18px;
        padding: 12px 24px;
    }

    .nav-cta-btn {
        display: none;
    }

    .theme-toggle {
        position: absolute;
        top: 12px;
        right: 52px;
    }

    .feed-filters {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }

    .feed-filter-btn {
        white-space: nowrap;
        flex-shrink: 0;
    }
}
