/* ═══════════════════════════════════════════════════════════════
   PIPWARE DASHBOARD — Design System & Styles
   ═══════════════════════════════════════════════════════════════ */

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

:root {
    /* Colors */
    --bg-primary: #07070d;
    --bg-secondary: #0d0d16;
    --bg-card: rgba(15, 15, 28, 0.7);
    --bg-card-hover: rgba(20, 20, 38, 0.8);
    --bg-glass: rgba(15, 15, 30, 0.5);
    --bg-input: rgba(12, 12, 24, 0.8);
    --border-subtle: rgba(120, 80, 255, 0.12);
    --border-hover: rgba(120, 80, 255, 0.3);
    --border-active: rgba(120, 80, 255, 0.5);

    /* Accent Gradient */
    --accent-1: #7c3aed;
    --accent-2: #3b82f6;
    --accent-3: #06b6d4;
    --gradient-brand: linear-gradient(135deg, var(--accent-1), var(--accent-2));
    --gradient-subtle: linear-gradient(135deg, rgba(124, 58, 237, 0.15), rgba(59, 130, 246, 0.1));

    /* Text */
    --text-primary: #e8e8f0;
    --text-secondary: #8888a8;
    --text-tertiary: #5a5a78;
    --text-accent: #a78bfa;

    /* Status */
    --green: #22c55e;
    --red: #ef4444;
    --yellow: #eab308;

    /* Spacing */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Font */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Background gradient orbs */
body::before,
body::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.15;
    pointer-events: none;
    z-index: 0;
}
body::before {
    width: 600px;
    height: 600px;
    background: var(--accent-1);
    top: -200px;
    right: -200px;
}
body::after {
    width: 500px;
    height: 500px;
    background: var(--accent-2);
    bottom: -150px;
    left: -150px;
}

/* ── Navbar ────────────────────────────────────────────────────── */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    height: 64px;
    background: rgba(7, 7, 13, 0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-subtle);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-icon {
    font-size: 1.5rem;
    filter: drop-shadow(0 0 8px rgba(124, 58, 237, 0.5));
}

.brand-text {
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: 0.15em;
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-tabs {
    display: flex;
    gap: 0.25rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 4px;
}

.nav-tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.25rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.25s ease;
}
.nav-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}
.nav-tab.active {
    color: var(--text-primary);
    background: var(--bg-card);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.nav-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--yellow);
    animation: pulse 2s ease-in-out infinite;
}
.status-dot.online {
    background: var(--green);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ── Tab Content ───────────────────────────────────────────────── */
.tab-content {
    display: none;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    position: relative;
    z-index: 1;
    animation: fadeIn 0.3s ease;
}
.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Stats Grid ────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1.5rem;
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    transition: all 0.3s ease;
}
.stat-card:hover {
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(124, 58, 237, 0.08);
}

.stat-icon {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    flex-shrink: 0;
}
.stat-icon-hits {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.2), rgba(124, 58, 237, 0.05));
    color: var(--accent-1);
}
.stat-icon-players {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(59, 130, 246, 0.05));
    color: var(--accent-2);
}
.stat-icon-latest {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(6, 182, 212, 0.05));
    color: var(--accent-3);
}

.stat-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.stat-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* ── Controls Bar ──────────────────────────────────────────────── */
.controls-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.search-wrapper {
    position: relative;
    flex: 1;
    max-width: 400px;
}
.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
}
.search-input {
    width: 100%;
    padding: 0.7rem 1rem 0.7rem 2.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    transition: all 0.25s ease;
    outline: none;
}
.search-input:focus {
    border-color: var(--border-active);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}
.search-input::placeholder {
    color: var(--text-tertiary);
}

.controls-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.auto-refresh-label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn:hover {
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
}
.btn:active {
    transform: scale(0.97);
}

.btn-sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.78rem;
}

.btn-primary {
    background: var(--gradient-brand);
    border: none;
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(124, 58, 237, 0.25);
}
.btn-primary:hover {
    box-shadow: 0 6px 24px rgba(124, 58, 237, 0.35);
    transform: translateY(-1px);
    background: var(--gradient-brand);
}
.btn-primary:active {
    transform: translateY(0) scale(0.98);
}
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-lg {
    padding: 0.9rem 2rem;
    font-size: 1rem;
    border-radius: var(--radius-md);
}

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

/* ── Table ─────────────────────────────────────────────────────── */
.table-wrapper {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.hits-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.hits-table thead {
    background: rgba(0, 0, 0, 0.3);
}
.hits-table th {
    padding: 0.9rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.hits-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    vertical-align: middle;
}

.hits-table tbody tr {
    transition: background 0.2s ease;
    animation: rowFadeIn 0.4s ease backwards;
}
.hits-table tbody tr:hover {
    background: var(--bg-card-hover);
}

@keyframes rowFadeIn {
    from { opacity: 0; transform: translateX(-8px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Stagger row animations */
.hits-table tbody tr:nth-child(1) { animation-delay: 0.02s; }
.hits-table tbody tr:nth-child(2) { animation-delay: 0.04s; }
.hits-table tbody tr:nth-child(3) { animation-delay: 0.06s; }
.hits-table tbody tr:nth-child(4) { animation-delay: 0.08s; }
.hits-table tbody tr:nth-child(5) { animation-delay: 0.10s; }
.hits-table tbody tr:nth-child(6) { animation-delay: 0.12s; }
.hits-table tbody tr:nth-child(7) { animation-delay: 0.14s; }
.hits-table tbody tr:nth-child(8) { animation-delay: 0.16s; }
.hits-table tbody tr:nth-child(9) { animation-delay: 0.18s; }
.hits-table tbody tr:nth-child(10) { animation-delay: 0.20s; }

.col-id { width: 50px; }
.col-token { min-width: 160px; }
.col-time { white-space: nowrap; }

/* Token cell */
.token-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}
.token-masked {
    color: var(--text-tertiary);
    letter-spacing: 0.05em;
}
.token-copy {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(124, 58, 237, 0.1);
    border: 1px solid rgba(124, 58, 237, 0.2);
    border-radius: var(--radius-sm);
    color: var(--text-accent);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.token-copy:hover {
    background: rgba(124, 58, 237, 0.25);
    border-color: var(--accent-1);
    transform: scale(1.05);
}
.token-copy.copied {
    background: rgba(34, 197, 94, 0.15);
    border-color: var(--green);
    color: var(--green);
}

.uuid-text {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.ip-text {
    font-family: var(--font-mono);
    font-size: 0.82rem;
}

.time-text {
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.username-text {
    font-weight: 600;
    color: var(--text-primary);
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 3rem;
    color: var(--text-tertiary);
}
.empty-state svg {
    opacity: 0.3;
}

.empty-row td {
    border-bottom: none !important;
}

/* ── Pagination ────────────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1.5rem 0;
}

.page-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ── Builder ───────────────────────────────────────────────────── */
.builder-container {
    max-width: 680px;
    margin: 0 auto;
}

.builder-header {
    text-align: center;
    margin-bottom: 2rem;
}
.builder-header h1 {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.builder-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Mode Toggle */
.mode-toggle {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 5px;
}
.mode-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.75rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.25s ease;
}
.mode-btn:hover {
    color: var(--text-primary);
}
.mode-btn.active {
    color: var(--text-primary);
    background: var(--bg-card);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

/* Glass Panel */
.glass-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(24px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 2rem;
}

/* Form */
.form-group {
    margin-bottom: 1.25rem;
}
.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.form-input {
    width: 100%;
    padding: 0.7rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    transition: all 0.25s ease;
    outline: none;
}
.form-input:focus {
    border-color: var(--border-active);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}
.form-hint {
    display: block;
    margin-top: 0.4rem;
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.form-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1rem;
}

.form-actions {
    display: flex;
    justify-content: center;
    margin-top: 1.5rem;
}

/* Drop Zone */
.drop-zone {
    position: relative;
    border: 2px dashed var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 2.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}
.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--accent-1);
    background: rgba(124, 58, 237, 0.05);
}
.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
}
.drop-zone-content svg {
    color: var(--text-tertiary);
}
.drop-zone-content span {
    font-size: 0.8rem;
    color: var(--text-tertiary);
}
.drop-zone-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding: 0.6rem 1rem;
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: var(--radius-sm);
    color: var(--green);
    font-size: 0.85rem;
}
.file-info #file-size {
    color: var(--text-secondary);
    margin-left: auto;
}
.btn-remove {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
}
.btn-remove:hover {
    color: var(--red);
}

/* Build Progress */
.build-progress {
    margin-top: 1.5rem;
    text-align: center;
}
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-secondary);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}
.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--gradient-brand);
    border-radius: 3px;
    transition: width 0.4s ease;
}
.progress-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Build Log */
.build-log {
    margin-top: 1.25rem;
    padding: 1rem;
}
.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.log-output {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.6;
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}
.log-output .log-success { color: var(--green); }
.log-output .log-error { color: var(--red); }
.log-output .log-info { color: var(--accent-2); }

/* ── Toast ─────────────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 9999;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.8rem 1.25rem;
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    color: var(--text-primary);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    animation: toastIn 0.35s ease;
    min-width: 250px;
}

/* ── Login Overlay ─────────────────────────────────────────────── */
.login-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at center, #1a1a2e 0%, #07070d 100%);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0.4s, opacity 0.4s ease;
    overflow: hidden;
}
.login-overlay::before, .login-overlay::after {
    content: '';
    position: absolute;
    width: 60vw;
    height: 60vw;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.15;
    animation: drift 15s infinite alternate ease-in-out;
    z-index: 0;
}
.login-overlay::before {
    background: var(--accent-1);
    top: -20%;
    left: -10%;
}
.login-overlay::after {
    background: var(--accent-2);
    bottom: -20%;
    right: -10%;
    animation-delay: -7.5s;
}
@keyframes drift {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(10%, 10%) scale(1.1); }
}

.login-overlay.active {
    visibility: visible;
    opacity: 1;
}
.login-overlay.active .login-box {
    transform: translateY(0) scale(1);
    opacity: 1;
}
.login-box {
    width: 100%;
    max-width: 420px;
    padding: 3.5rem 2.5rem;
    position: relative;
    z-index: 1;
    transform: translateY(30px) scale(0.95);
    opacity: 0;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.5s ease;
    background: rgba(15, 15, 28, 0.85);
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(124, 58, 237, 0.15);
}
.toast.toast-success { border-left: 3px solid var(--green); }
.toast.toast-error { border-left: 3px solid var(--red); }
.toast.toast-info { border-left: 3px solid var(--accent-2); }

.toast-exit {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}

/* ── Utilities ─────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .navbar {
        padding: 0 1rem;
        height: 56px;
    }
    .nav-status { display: none; }
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .tab-content {
        padding: 1rem;
    }
    .controls-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .search-wrapper {
        max-width: none;
    }
    .controls-right {
        justify-content: flex-end;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .hits-table {
        font-size: 0.78rem;
    }
    .col-uuid, .col-sip {
        display: none;
    }
}

/* ── Scrollbar ─────────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(120, 80, 255, 0.2);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(120, 80, 255, 0.35);
}
