/* ============================================
   PingFlow — Lead Distribution Platform
   Clean, professional UI
   ============================================ */

:root {
    --sidebar-width: 240px;
    --sidebar-bg: #1a1d29;
    --sidebar-hover: #252836;
    --sidebar-active: #2d3142;
    --accent: #4f6ef7;
    --accent-light: #6b84f9;
    --accent-glow: rgba(79, 110, 247, 0.15);
    --success: #2ecc71;
    --danger: #e74c3c;
    --warning: #f39c12;
    --info: #3498db;
    --body-bg: #f5f7fb;
    --card-bg: #ffffff;
    --text-primary: #2d3142;
    --text-secondary: #6c757d;
    --border-color: #e9ecef;
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--body-bg);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

/* ---- Sidebar ---- */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #b0b5c9;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
}

.logo i {
    color: var(--accent);
    font-size: 1.3rem;
}

.sidebar-nav {
    list-style: none;
    padding: 12px 0;
    margin: 0;
    flex: 1;
    overflow-y: auto;
}

.sidebar-nav .nav-section {
    padding: 20px 20px 8px;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 1.2px;
    color: #5a5f78;
    text-transform: uppercase;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: #8b90a7;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 400;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
}

.sidebar-nav li a:hover {
    color: #d1d4e0;
    background: var(--sidebar-hover);
}

.sidebar-nav li.active a {
    color: #fff;
    background: var(--sidebar-active);
    border-left-color: var(--accent);
    font-weight: 500;
}

.sidebar-nav li a i {
    width: 18px;
    text-align: center;
    font-size: 0.9rem;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-footer .text-muted {
    color: #8b90a7 !important;
}

.sidebar-footer .small,
.sidebar-footer div {
    color: #8b90a7;
}

/* ---- Main Content ---- */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 28px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.sidebar-toggle {
    color: var(--text-secondary);
    font-size: 1.2rem;
    padding: 4px 8px;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: auto;
    font-size: 0.85rem;
}

.content-wrapper {
    padding: 24px 28px;
}

/* ---- Page Headers ---- */
.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 4px;
}

.page-header p {
    color: var(--text-secondary);
    margin: 0;
    font-size: 0.875rem;
}

/* ---- Stat Cards ---- */
.stat-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px 22px;
    border: 1px solid var(--border-color);
    transition: box-shadow 0.2s;
    height: 100%;
}

.stat-card:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}

.stat-card .stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    margin-bottom: 14px;
}

.stat-icon.blue   { background: rgba(79,110,247,0.1);  color: var(--accent); }
.stat-icon.green  { background: rgba(46,204,113,0.1);  color: var(--success); }
.stat-icon.orange { background: rgba(243,156,18,0.1);  color: var(--warning); }
.stat-icon.red    { background: rgba(231,76,60,0.1);   color: var(--danger); }
.stat-icon.cyan   { background: rgba(52,152,219,0.1);  color: var(--info); }

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 6px;
}

.stat-card .stat-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ---- Cards ---- */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: none;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body {
    padding: 20px;
}

/* ---- Tables ---- */
.table {
    margin-bottom: 0;
    font-size: 0.85rem;
}

.table thead th {
    background: #f8f9fc;
    border-bottom: 2px solid var(--border-color);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    padding: 12px 16px;
    white-space: nowrap;
}

.table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    border-bottom: 1px solid #f0f2f5;
}

.table tbody tr:hover {
    background: #f8f9fc;
}

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

/* ---- Badges ---- */
.badge {
    font-weight: 500;
    font-size: 0.72rem;
    padding: 4px 10px;
    border-radius: 6px;
    letter-spacing: 0.3px;
}

/* ---- Buttons ---- */
.btn-accent {
    background: var(--accent);
    color: #fff;
    border: none;
    font-weight: 500;
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 0.875rem;
    transition: all 0.15s;
}

.btn-accent:hover {
    background: var(--accent-light);
    color: #fff;
    box-shadow: 0 4px 12px rgba(79,110,247,0.25);
}

/* ---- Activity Feed ---- */
.activity-item {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #f0f2f5;
    font-size: 0.83rem;
}

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

.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
}

.activity-dot.sold     { background: var(--success); }
.activity-dot.rejected { background: var(--danger); }
.activity-dot.created  { background: var(--info); }
.activity-dot.ping_start { background: var(--warning); }
.activity-dot.no_buyers  { background: var(--text-secondary); }

.activity-time {
    color: var(--text-secondary);
    font-size: 0.72rem;
    white-space: nowrap;
}

/* ---- Lead Detail ---- */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.detail-item {
    padding: 12px 16px;
    background: #f8f9fc;
    border-radius: 8px;
}

.detail-item .label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 4px;
}

.detail-item .value {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
    word-break: break-word;
}

/* ---- Bid Comparison Bar ---- */
.bid-bar-wrapper {
    margin-bottom: 16px;
}

.bid-bar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.bid-bar-name {
    font-weight: 600;
    font-size: 0.85rem;
}

.bid-bar-amount {
    font-weight: 700;
    font-size: 0.95rem;
}

.bid-bar {
    height: 32px;
    border-radius: 8px;
    background: #e9ecef;
    overflow: hidden;
    position: relative;
}

.bid-bar-fill {
    height: 100%;
    border-radius: 8px;
    transition: width 0.8s ease;
    display: flex;
    align-items: center;
    padding-left: 12px;
    color: #fff;
    font-weight: 500;
    font-size: 0.75rem;
}

.bid-bar-fill.winner {
    background: linear-gradient(90deg, #2ecc71, #27ae60);
}

.bid-bar-fill.loser {
    background: linear-gradient(90deg, #95a5a6, #7f8c8d);
}

.bid-bar-fill.rejected {
    background: linear-gradient(90deg, #e74c3c, #c0392b);
}

.winner-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(46,204,113,0.12);
    color: #27ae60;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
}

/* ---- Form Styling ---- */
.form-label {
    font-weight: 500;
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid #dde1e8;
    padding: 8px 14px;
    font-size: 0.875rem;
    transition: border-color 0.15s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ---- API Docs ---- */
.code-block {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 16px 20px;
    border-radius: 10px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.8rem;
    overflow-x: auto;
    line-height: 1.6;
}

.code-block .key   { color: #89b4fa; }
.code-block .str   { color: #a6e3a1; }
.code-block .num   { color: #fab387; }
.code-block .comment { color: #6c7086; font-style: italic; }

.endpoint-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    font-weight: 600;
}

.endpoint-badge.post {
    background: rgba(46,204,113,0.12);
    color: #27ae60;
}

.endpoint-badge.get {
    background: rgba(52,152,219,0.12);
    color: #2980b9;
}

/* ---- Buyer Cards ---- */
.buyer-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    transition: box-shadow 0.2s;
}

.buyer-card:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}

.buyer-card .buyer-avatar {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
}

.buyer-card .buyer-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.buyer-card .buyer-stat-value {
    font-size: 1.1rem;
    font-weight: 700;
}

.buyer-card .buyer-stat-label {
    font-size: 0.68rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    color: #d1d5e0;
}

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

/* ---- Responsive ---- */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .content-wrapper {
        padding: 16px;
    }
}

/* ---- Ping Animation ---- */
@keyframes ping-pulse {
    0% { box-shadow: 0 0 0 0 rgba(79,110,247,0.4); }
    70% { box-shadow: 0 0 0 10px rgba(79,110,247,0); }
    100% { box-shadow: 0 0 0 0 rgba(79,110,247,0); }
}

.pinging {
    animation: ping-pulse 1.5s infinite;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5e0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #b0b5c9; }

/* ---- Toast ---- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}
