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

:root {
    --green: #2e7d32;
    --green-light: #4caf50;
    --yellow: #f9a825;
    --red: #c62828;
    --red-light: #ef5350;
    --bg-dark: #1a1a2e;
    --bg-card: #16213e;
    --bg-input: #0f3460;
    --text-primary: #e0e0e0;
    --text-secondary: #9e9e9e;
    --text-bright: #ffffff;
    --accent: #e94560;
    --border: #333;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
}

/* ===== Top Bar ===== */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: var(--bg-card);
    border-bottom: 2px solid var(--green);
}

.logo {
    font-size: 1.3rem;
    color: var(--green-light);
    font-weight: 700;
    letter-spacing: 1px;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.connected { background: var(--green-light); box-shadow: 0 0 6px var(--green-light); }
.status-dot.disconnected { background: var(--red); }

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

.logout-btn {
    padding: 6px 14px;
    background: transparent;
    border: 1px solid var(--red);
    border-radius: 6px;
    color: var(--red-light);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: var(--red);
    color: white;
}

/* ===== Content ===== */
.content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

/* ===== Clock Container ===== */
.clock-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.clock-canvas {
    border-radius: 50%;
    box-shadow: 0 0 40px rgba(46, 125, 50, 0.3);
}

/* ===== Lot Info ===== */
.lot-info {
    text-align: center;
    padding: 12px 24px;
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.lot-info .product-name {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-bright);
}

.lot-info .lot-details {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 4px;
}

/* ===== Bid Button ===== */
.bid-btn {
    width: 220px;
    height: 220px;
    border-radius: 50%;
    border: 4px solid var(--red);
    background: linear-gradient(145deg, #c62828, #b71c1c);
    color: white;
    font-size: 2.2rem;
    font-weight: 800;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 3px;
    transition: all 0.15s ease;
    box-shadow: 0 6px 20px rgba(198, 40, 40, 0.4);
    position: relative;
    overflow: hidden;
}

.bid-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 8px 30px rgba(198, 40, 40, 0.6);
}

.bid-btn:active:not(:disabled) {
    transform: scale(0.97);
}

.bid-btn:disabled {
    background: #444;
    border-color: #555;
    color: #888;
    cursor: not-allowed;
    box-shadow: none;
}

.bid-btn.active {
    animation: pulse-bid 1.5s ease-in-out infinite;
}

@keyframes pulse-bid {
    0%, 100% { box-shadow: 0 6px 20px rgba(198, 40, 40, 0.4); }
    50% { box-shadow: 0 8px 40px rgba(198, 40, 40, 0.8); }
}

/* ===== Quantity Selector ===== */
.quantity-selector {
    text-align: center;
    padding: 16px 24px;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border);
    max-width: 500px;
    width: 100%;
}

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

.quantity-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.qty-btn {
    padding: 10px 18px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    min-width: 70px;
}

.qty-btn:hover {
    border-color: var(--green);
    background: rgba(46, 125, 50, 0.15);
}

.qty-btn.selected {
    border-color: var(--green-light);
    background: rgba(46, 125, 50, 0.25);
    color: var(--green-light);
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.3);
}

.quantity-selected {
    margin-top: 10px;
    font-size: 0.85rem;
    color: var(--green-light);
    font-weight: 600;
}

/* ===== Bid Status Panel ===== */
.bid-status {
    text-align: center;
    padding: 16px 24px;
    background: var(--bg-card);
    border-radius: 12px;
    border: 2px solid var(--border);
    max-width: 400px;
    width: 100%;
    transition: border-color 0.3s ease;
}

.bid-status.pending {
    border-color: #f9a825;
}

.bid-status.accepted {
    border-color: var(--green-light);
}

.bid-status.rejected {
    border-color: var(--red);
}

.bid-status.lost {
    border-color: #9e9e9e;
}

.bid-status-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
}

.bid-status-icon {
    font-size: 1.3rem;
    font-weight: 700;
}

.bid-status.pending .bid-status-icon { color: #f9a825; }
.bid-status.accepted .bid-status-icon { color: var(--green-light); }
.bid-status.rejected .bid-status-icon { color: var(--red); }
.bid-status.lost .bid-status-icon { color: #9e9e9e; }

.bid-status-label {
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bid-status.pending .bid-status-label { color: #f9a825; }
.bid-status.accepted .bid-status-label { color: var(--green-light); }
.bid-status.rejected .bid-status-label { color: var(--red); }
.bid-status.lost .bid-status-label { color: #9e9e9e; }

.bid-status-details {
    display: flex;
    justify-content: space-around;
    gap: 16px;
}

.bid-status-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.bid-status-key {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.bid-status-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* ===== Bidder Layout ===== */
.bidder-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

/* ===== Result Overlay ===== */
.result-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.result-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.result-card {
    background: var(--bg-card);
    border: 2px solid var(--green);
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    max-width: 400px;
}

.result-card.sold { border-color: var(--green); }
.result-card.unsold { border-color: var(--red); }

.result-card h2 {
    font-size: 2rem;
    margin-bottom: 16px;
}

.result-card .price {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--green-light);
}

/* ===== Recent Results ===== */
.recent-results {
    width: 100%;
    max-width: 600px;
}

.recent-results h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.result-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-card);
    border-radius: 6px;
    font-size: 0.85rem;
    border: 1px solid var(--border);
}

.result-item .result-product { color: var(--text-bright); }
.result-item .result-price { color: var(--green-light); font-weight: 600; }
.result-item .result-buyer { color: var(--text-secondary); }

/* ===== Admin Layout ===== */
.admin-layout {
    display: grid;
    grid-template-columns: 300px 1fr 300px;
    gap: 24px;
    min-height: calc(100vh - 100px);
}

.admin-panel {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border);
}

.admin-panel h2 {
    font-size: 1.1rem;
    color: var(--green-light);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
}

/* Lot Queue */
.lot-queue-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 500px;
    overflow-y: auto;
}

.lot-queue-item {
    padding: 10px 12px;
    background: var(--bg-input);
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: border-color 0.2s;
}

.lot-queue-item:hover { border-color: var(--green); }
.lot-queue-item.selected { border-color: var(--green-light); background: rgba(46, 125, 50, 0.15); }

.lot-queue-item .lot-name { font-weight: 600; color: var(--text-bright); }
.lot-queue-item .lot-meta { font-size: 0.8rem; color: var(--text-secondary); }

/* Admin Controls */
.admin-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.control-btn {
    padding: 12px 32px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    width: 200px;
    transition: opacity 0.2s;
}

.control-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.control-btn.start { background: var(--green); color: white; }
.control-btn.stop { background: var(--red); color: white; }
.control-btn.skip { background: var(--yellow); color: #333; }

/* Create Lot Form */
.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-transform: uppercase;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--green);
}

.form-submit {
    width: 100%;
    padding: 10px;
    background: var(--green);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
}

/* History Table */
.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.history-table th {
    text-align: left;
    padding: 6px 8px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.history-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
}

/* ===== Login Page ===== */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 100px);
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px;
    width: 400px;
    text-align: center;
}

.login-card h2 {
    color: var(--green-light);
    margin-bottom: 24px;
}

.login-card .form-group {
    text-align: left;
}

.login-btn {
    width: 100%;
    padding: 14px;
    background: var(--green);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 16px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

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

/* ===== Waiting State ===== */
.waiting-message {
    text-align: center;
    color: var(--text-secondary);
    font-size: 1.2rem;
    padding: 40px;
}

.waiting-message .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--green);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 16px auto;
}

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

/* ===== Bid Count Indicator ===== */
.bid-count {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--yellow);
    background: var(--bg-card);
    border: 1px solid var(--yellow);
    border-radius: 20px;
    padding: 6px 18px;
    text-align: center;
    animation: pulse-count 2s ease-in-out infinite;
}

@keyframes pulse-count {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.admin-bid-count {
    margin-top: 8px;
}

/* ===== Bid Status: Placed State ===== */
.bid-status.placed {
    border-color: #2196f3;
}

.bid-status.placed .bid-status-icon { color: #2196f3; }
.bid-status.placed .bid-status-label { color: #2196f3; }

/* ===== Allocation Table (Result Overlay) ===== */
.allocation-table {
    text-align: left;
    width: 100%;
    margin-top: 8px;
}

.alloc-header {
    display: grid;
    grid-template-columns: 50px 1fr 90px 80px;
    gap: 4px;
    padding: 6px 8px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.alloc-row {
    display: grid;
    grid-template-columns: 50px 1fr 90px 80px;
    gap: 4px;
    padding: 8px;
    font-size: 0.85rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.alloc-row.me {
    background: rgba(46, 125, 50, 0.15);
    border-radius: 6px;
    color: var(--green-light);
    font-weight: 600;
}

.result-card.sold {
    max-width: 500px;
}

/* ===== Reports Page ===== */
.reports-layout {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.reports-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.reports-header h2 {
    font-size: 1.3rem;
    color: var(--green-light);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.filter-bar {
    display: flex;
    gap: 8px;
}

.filter-btn {
    padding: 8px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

.filter-btn.active {
    border-color: var(--green-light);
    background: rgba(46, 125, 50, 0.15);
    color: var(--green-light);
}

.back-link {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--green-light);
}

.report-table-wrap {
    overflow-x: auto;
}

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

.report-table thead th {
    text-align: left;
    padding: 10px 12px;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.report-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.report-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.report-row .lot-id {
    font-weight: 700;
    color: var(--text-bright);
}

.report-row .date-cell {
    font-size: 0.78rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.status-badge.sold {
    background: rgba(46, 125, 50, 0.2);
    color: var(--green-light);
    border: 1px solid var(--green);
}

.status-badge.unsold {
    background: rgba(198, 40, 40, 0.2);
    color: var(--red-light);
    border: 1px solid var(--red);
}

.status-badge.pending {
    background: rgba(249, 168, 37, 0.15);
    color: var(--yellow);
    border: 1px solid var(--yellow);
}

.status-badge.active {
    background: rgba(33, 150, 243, 0.15);
    color: #64b5f6;
    border: 1px solid #2196f3;
}

/* Inline Allocations in Report Table */
.alloc-cell {
    min-width: 200px;
}

.alloc-inline {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 3px 0;
    font-size: 0.8rem;
}

.alloc-inline + .alloc-inline {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.alloc-buyer {
    color: var(--text-bright);
    font-weight: 600;
}

.alloc-detail {
    color: var(--green-light);
    white-space: nowrap;
}

.no-data {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* Balance Column */
.balance-cell {
    white-space: nowrap;
    font-weight: 600;
    font-size: 0.85rem;
}

.balance-zero {
    color: var(--green-light);
}

.balance-remaining {
    color: var(--yellow);
}

.balance-full {
    color: var(--text-secondary);
}

.report-empty {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-size: 1rem;
}

/* ===== Responsive ===== */
@media (max-width: 1000px) {
    .admin-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .clock-canvas {
        width: 320px !important;
        height: 320px !important;
    }
    .bid-btn {
        width: 160px;
        height: 160px;
        font-size: 1.6rem;
    }
    .qty-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
        min-width: 56px;
    }
    .quantity-selector {
        padding: 12px 16px;
    }
}
