/* dealer.css — Dealer Management Page */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:     #06070d;
    --bg2:    #0d0f1a;
    --bg3:    #141828;
    --border: #1e2540;
    --gold:   #f59e0b;
    --green:  #10b981;
    --red:    #ef4444;
    --blue:   #3b82f6;
    --text:   #e2e8f0;
    --muted:  #64748b;
    --font:   'Segoe UI', Tahoma, system-ui, sans-serif;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); direction: rtl; overflow: hidden; }

/* ── Auth error ── */
.auth-error {
    position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
    background: var(--bg);
}
.auth-box {
    background: var(--bg2); border: 1px solid var(--border); border-radius: 20px;
    padding: 40px 32px; text-align: center; max-width: 360px; width: 90%;
}
.auth-box h2 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.auth-box p  { color: var(--muted); font-size: 14px; line-height: 1.6; margin-bottom: 20px; }
.btn-go-app {
    display: inline-block; padding: 11px 28px;
    background: linear-gradient(135deg,#1d4ed8,#3b82f6);
    color: #fff; border-radius: 10px; font-size: 14px; font-weight: 700;
    text-decoration: none;
}
.hidden { display: none !important; }

/* ── App layout ── */
#app { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
    width: 260px; min-width: 260px; background: var(--bg2);
    border-left: 1px solid var(--border); display: flex; flex-direction: column;
    overflow: hidden;
}
.sidebar-header {
    padding: 16px; border-bottom: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 10px;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-icon { font-size: 20px; }
.brand-name { font-size: 16px; font-weight: 800; color: var(--gold); }
.btn-new-room {
    width: 100%; padding: 9px; background: linear-gradient(135deg,#059669,#10b981);
    color: #fff; border: none; border-radius: 10px; font-size: 13px; font-weight: 700;
    cursor: pointer; font-family: var(--font);
}
.btn-new-room:hover { opacity: 0.9; }

.sidebar-label { padding: 10px 16px 4px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }

.room-list { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.room-empty { text-align: center; color: var(--muted); font-size: 12px; padding: 24px 0; }

.room-item {
    padding: 10px 12px; border-radius: 10px; cursor: pointer; border: 1px solid transparent;
    transition: all 0.15s;
}
.room-item:hover { background: var(--bg3); }
.room-item.active { background: var(--bg3); border-color: var(--gold); }
.room-item-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 3px; }
.room-item-id { font-size: 12px; font-family: monospace; color: var(--gold); font-weight: 700; }
.room-status { font-size: 10px; padding: 2px 7px; border-radius: 6px; font-weight: 600; }
.status-draft  { background: rgba(100,116,139,0.2); color: var(--muted); }
.status-active { background: rgba(16,185,129,0.2); color: var(--green); }
.status-closed { background: rgba(30,37,64,0.5); color: var(--muted); }
.room-item-sub { font-size: 11px; color: var(--muted); }

.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--border); }
.back-link { font-size: 12px; color: var(--muted); text-decoration: none; }
.back-link:hover { color: var(--text); }

/* ── Main content ── */
.main-content { flex: 1; overflow-y: auto; }
.view { padding: 24px; }

/* ── Welcome ── */
.welcome-box {
    max-width: 480px; margin: 80px auto; text-align: center;
    background: var(--bg2); border: 1px solid var(--border); border-radius: 20px; padding: 48px 32px;
}
.welcome-icon { font-size: 56px; margin-bottom: 16px; }
.welcome-box h2 { font-size: 22px; font-weight: 800; color: var(--gold); margin-bottom: 10px; }
.welcome-box p  { color: var(--muted); font-size: 14px; line-height: 1.7; margin-bottom: 24px; }
.btn-create-big {
    padding: 13px 32px; background: linear-gradient(135deg,#059669,#10b981);
    color: #fff; border: none; border-radius: 12px; font-size: 16px; font-weight: 700;
    cursor: pointer; font-family: var(--font);
}

/* ── View header ── */
.view-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;
}
.view-header h2 { font-size: 18px; font-weight: 800; }
.btn-back {
    padding: 7px 16px; background: transparent; border: 1px solid var(--border);
    border-radius: 8px; color: var(--muted); font-size: 13px; cursor: pointer;
    font-family: var(--font);
}

/* ── Create form ── */
.create-form-wrap { max-width: 680px; display: flex; flex-direction: column; gap: 20px; }
.form-section {
    background: var(--bg2); border: 1px solid var(--border); border-radius: 14px; padding: 20px;
}
.section-title { font-size: 13px; font-weight: 700; color: var(--gold); margin-bottom: 14px; }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-group { flex: 1; min-width: 140px; margin-bottom: 12px; }
.form-group label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.form-group input, .form-group select {
    width: 100%; padding: 9px 12px; background: var(--bg3);
    border: 1px solid var(--border); border-radius: 8px;
    color: var(--text); font-size: 14px; font-family: var(--font);
    outline: none; transition: border 0.2s;
}
.form-group input:focus, .form-group select:focus { border-color: var(--blue); }
.form-group select option { background: var(--bg3); }

/* ── Customer select list ── */
.customer-search-wrap { margin-bottom: 10px; }
.customer-search-wrap input {
    width: 100%; padding: 8px 12px; background: var(--bg3);
    border: 1px solid var(--border); border-radius: 8px;
    color: var(--text); font-size: 13px; font-family: var(--font); outline: none;
}
.customer-select-list {
    max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px;
}
.cust-loading { color: var(--muted); font-size: 12px; padding: 8px 0; }
.cust-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px;
    border-radius: 8px; cursor: pointer; border: 1px solid transparent; transition: all 0.15s;
}
.cust-item:hover { background: var(--bg3); }
.cust-item.selected { background: rgba(59,130,246,0.1); border-color: var(--blue); }
.cust-check { width: 16px; height: 16px; border-radius: 4px; border: 2px solid var(--border); flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.cust-item.selected .cust-check { background: var(--blue); border-color: var(--blue); }
.cust-check::after { content: '✓'; font-size: 11px; color: #fff; display: none; }
.cust-item.selected .cust-check::after { display: block; }
.cust-name { font-size: 13px; font-weight: 600; }
.cust-phone { font-size: 11px; color: var(--muted); direction: ltr; }

.selected-count { font-size: 12px; color: var(--blue); margin-top: 8px; font-weight: 600; }
.btn-create-submit {
    padding: 14px; background: linear-gradient(135deg,#1d4ed8,#3b82f6);
    color: #fff; border: none; border-radius: 12px; font-size: 15px; font-weight: 700;
    cursor: pointer; font-family: var(--font); width: 100%;
}
.btn-create-submit:disabled { opacity: 0.5; cursor: not-allowed; }
.create-error { font-size: 12px; color: var(--red); margin-top: 6px; }

/* ── Invite links ── */
.invite-card {
    background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
    padding: 14px 16px; margin-bottom: 10px; display: flex; align-items: center; gap: 12px;
    flex-wrap: wrap;
}
.inv-name { font-size: 13px; font-weight: 600; flex: 1; min-width: 120px; }
.inv-masked { font-size: 11px; color: var(--muted); }
.inv-actions { display: flex; gap: 8px; flex-shrink: 0; }
.btn-wa {
    padding: 7px 14px; background: #25D366; color: #fff; border: none;
    border-radius: 8px; font-size: 13px; font-weight: 700; cursor: pointer;
    font-family: var(--font); text-decoration: none; display: inline-block;
}
.btn-copy-link {
    padding: 7px 12px; background: transparent; border: 1px solid var(--border);
    color: var(--muted); border-radius: 8px; font-size: 12px; cursor: pointer;
    font-family: var(--font);
}
.btn-copy-link:hover { color: var(--text); border-color: var(--text); }

.start-room-wrap { margin-top: 20px; text-align: center; }
.start-hint { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.btn-start-room {
    padding: 14px 40px; background: linear-gradient(135deg,#7c3aed,#8b5cf6);
    color: #fff; border: none; border-radius: 12px; font-size: 16px; font-weight: 800;
    cursor: pointer; font-family: var(--font); letter-spacing: 0.5px;
}
.btn-start-room:hover { opacity: 0.9; }

/* ── Room dashboard ── */
.room-dashboard { display: flex; flex-direction: column; height: 100%; }
.room-info-bar {
    display: flex; align-items: center; gap: 12px; padding: 12px 16px;
    background: var(--bg2); border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.info-chip {
    display: flex; flex-direction: column; padding: 4px 12px;
    border: 1px solid var(--border); border-radius: 8px; background: var(--bg3);
}
.chip-label { font-size: 10px; color: var(--muted); }
.chip-val { font-size: 13px; font-weight: 700; }

.dealer-body {
    display: grid; grid-template-columns: 1fr 300px;
    flex: 1; overflow: hidden; height: calc(100vh - 56px);
}

/* ── Dealer bid board ── */
.dealer-bid-board {
    display: flex; flex-direction: column; border-left: 1px solid var(--border); overflow: hidden;
}
.board-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 16px; font-size: 13px; font-weight: 600;
    border-bottom: 1px solid var(--border); background: var(--bg2);
}
.room-timer-wrap { display: flex; align-items: center; gap: 6px; }
.room-timer { font-size: 14px; font-weight: 800; color: var(--gold); font-family: monospace; }
.board-live { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--red); font-weight: 700; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red); animation: blink 1s ease-in-out infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.2} }

.dealer-bid-list { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.bid-empty-d { text-align: center; color: var(--muted); font-size: 13px; padding: 40px 0; }

.dealer-bid-item {
    display: flex; align-items: center; gap: 10px;
    background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
    padding: 10px 14px; cursor: pointer; transition: all 0.2s;
    animation: bidIn 0.3s ease-out;
}
@keyframes bidIn { from{opacity:0;transform:translateY(-8px)} to{opacity:1;transform:none} }
.dealer-bid-item:hover { border-color: var(--blue); background: rgba(59,130,246,0.06); }
.dealer-bid-item.selected { border-color: var(--gold); background: rgba(245,158,11,0.08); }
.dealer-bid-item.top { border-color: var(--gold); }

.d-rank { font-size: 11px; color: var(--muted); min-width: 18px; }
.d-info { flex: 1; }
.d-names { display: flex; gap: 6px; align-items: center; margin-bottom: 2px; }
.d-realname { font-size: 12px; font-weight: 600; color: var(--text); }
.d-masked { font-size: 11px; color: var(--muted); }
.d-auto-tag { font-size: 10px; background: rgba(59,130,246,0.2); color: var(--blue); border-radius: 4px; padding: 1px 5px; }
.d-rate { font-size: 18px; font-weight: 800; color: var(--text); font-family: monospace; }
.dealer-bid-item.top .d-rate { color: var(--gold); }
.d-amount { font-size: 11px; color: var(--muted); }
.d-time { font-size: 10px; color: var(--muted); white-space: nowrap; }

/* ── Right panel ── */
.dealer-right { overflow-y: auto; display: flex; flex-direction: column; gap: 0; }

.dealer-stats {
    padding: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
    border-bottom: 1px solid var(--border); background: var(--bg2);
}
.d-stat { background: var(--bg3); border-radius: 8px; padding: 10px 12px; }
.d-stat-label { font-size: 10px; color: var(--muted); margin-bottom: 4px; }
.d-stat-val { font-size: 15px; font-weight: 800; font-family: monospace; }

.selected-bid-panel {
    padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.panel-title { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 10px; }
.selected-bid-info { font-size: 13px; color: var(--muted); }
.btn-accept-bid {
    width: 100%; padding: 10px; background: linear-gradient(135deg,#059669,#10b981);
    color: #fff; border: none; border-radius: 9px; font-size: 14px; font-weight: 700;
    cursor: pointer; font-family: var(--font); margin-bottom: 8px;
}
.btn-counter-bid {
    width: 100%; padding: 10px; background: transparent;
    border: 1px solid var(--blue); color: var(--blue);
    border-radius: 9px; font-size: 14px; font-weight: 600;
    cursor: pointer; font-family: var(--font);
}

.counter-form {
    padding: 14px 16px; border-bottom: 1px solid var(--border); background: rgba(245,158,11,0.04);
}
.btn-send-counter {
    flex: 1; padding: 9px; background: var(--gold); color: #000;
    border: none; border-radius: 8px; font-size: 13px; font-weight: 700;
    cursor: pointer; font-family: var(--font);
}
.btn-cancel-counter {
    flex: 1; padding: 9px; background: transparent; border: 1px solid var(--border);
    color: var(--muted); border-radius: 8px; font-size: 13px; cursor: pointer;
    font-family: var(--font);
}

.room-controls { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.btn-close-room {
    width: 100%; padding: 10px; background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.3); color: var(--red);
    border-radius: 9px; font-size: 13px; font-weight: 700;
    cursor: pointer; font-family: var(--font);
}
.btn-close-room:hover { background: rgba(239,68,68,0.2); }

.invite-resend { padding: 14px 16px; }
.resend-title { font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.resend-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 12px;
}
.resend-item:last-child { border-bottom: none; }
.resend-name { color: var(--text); }
.resend-btns { display: flex; gap: 6px; }
.btn-resend-wa {
    padding: 3px 9px; background: #25D366; color: #fff; border: none;
    border-radius: 6px; font-size: 11px; font-weight: 700; cursor: pointer;
    text-decoration: none; font-family: var(--font);
}
.btn-resend-copy {
    padding: 3px 8px; background: transparent; border: 1px solid var(--border);
    color: var(--muted); border-radius: 6px; font-size: 11px; cursor: pointer;
    font-family: var(--font);
}

/* ── Toast ── */
.toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
    background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
    padding: 10px 20px; font-size: 13px; color: var(--text);
    opacity: 0; transition: all 0.3s; pointer-events: none; z-index: 300; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error   { border-color: var(--red);   color: var(--red);   }
.toast.info    { border-color: var(--blue);  color: var(--blue);  }

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
