/* ══════════════════════════════════════════════
   📄 PAPER TRADING / SIMULATION — Feature 13.2
   Virtual portfolio with fake Rp 100 juta
   ══════════════════════════════════════════════ */

/* ── Page Header ── */
.paper-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0 12px;
    flex-wrap: wrap;
    gap: 10px;
}
.paper-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary, #fff);
    margin: 0;
}
.paper-title svg { width: 24px; height: 24px; color: #f59e0b; }
.paper-subtitle {
    font-size: 13px;
    color: var(--text-muted, #94a3b8);
    margin-top: 4px;
}

/* Paper Mode Badge */
.paper-mode-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 20px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border: 1px solid rgba(245, 158, 11, 0.3);
    animation: paperPulse 2s ease-in-out infinite;
}
.paper-mode-badge svg { width: 14px; height: 14px; }
@keyframes paperPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ── Dashboard Stats Cards ── */
.paper-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.paper-stat-card {
    background: var(--bg-elevated, #1e293b);
    border: 1px solid var(--border-color, rgba(255,255,255,0.06));
    border-radius: 14px;
    padding: 16px;
    position: relative;
    overflow: hidden;
}
.paper-stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--accent, #6366f1);
}
.paper-stat-card.positive::before { background: #22c55e; }
.paper-stat-card.negative::before { background: #ef4444; }
.paper-stat-card.warning::before  { background: #f59e0b; }
.paper-stat-card.cash::before     { background: #3b82f6; }

.paper-stat-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted, #94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.paper-stat-value {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary, #fff);
    line-height: 1.2;
}
.paper-stat-value.positive { color: #22c55e; }
.paper-stat-value.negative { color: #ef4444; }
.paper-stat-sub {
    font-size: 12px;
    font-weight: 500;
    margin-top: 4px;
}
.paper-stat-sub.positive { color: #22c55e; }
.paper-stat-sub.negative { color: #ef4444; }

/* ── Section Container ── */
.paper-section {
    background: var(--bg-elevated, #1e293b);
    border: 1px solid var(--border-color, rgba(255,255,255,0.06));
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 16px;
}
.paper-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 8px;
}
.paper-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary, #fff);
}
.paper-section-title svg { width: 18px; height: 18px; color: #f59e0b; }

/* ── Trade Form ── */
.paper-trade-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}
.paper-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.paper-form-group.full-width { grid-column: 1 / -1; }

.paper-form-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted, #94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.paper-form-input {
    background: var(--bg-card, #0f172a);
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    color: var(--text-primary, #fff);
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.2s;
}
.paper-form-input:focus {
    border-color: #f59e0b;
}
.paper-form-input::placeholder {
    color: var(--text-muted, #64748b);
    font-weight: 400;
}

/* Stock search autocomplete */
.paper-stock-wrapper {
    position: relative;
}
.paper-stock-ac {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: var(--bg-elevated, #1e293b);
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 10px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 50;
    display: none;
}
.paper-stock-ac.open { display: block; }
.paper-ac-item {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 13px;
}
.paper-ac-item:hover, .paper-ac-item.active {
    background: rgba(245, 158, 11, 0.08);
}
.paper-ac-code { font-weight: 700; color: var(--text-primary, #fff); min-width: 55px; }
.paper-ac-name { color: var(--text-muted, #94a3b8); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Direction Tabs */
.paper-dir-tabs {
    display: flex;
    gap: 8px;
}
.paper-dir-btn {
    flex: 1;
    padding: 10px;
    border: 2px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 10px;
    background: transparent;
    color: var(--text-muted, #94a3b8);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}
.paper-dir-btn.buy.active {
    background: rgba(34, 197, 94, 0.15);
    border-color: #22c55e;
    color: #22c55e;
}
.paper-dir-btn.sell.active {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
    color: #ef4444;
}
.paper-dir-btn:hover:not(.active) {
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text-primary, #fff);
}

/* Order Preview */
.paper-order-preview {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: rgba(245, 158, 11, 0.06);
    border: 1px dashed rgba(245, 158, 11, 0.2);
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 12px;
}
.paper-order-total {
    font-size: 16px;
    font-weight: 800;
    color: var(--text-primary, #fff);
}

/* Submit Button */
.paper-submit-btn {
    width: 100%;
    padding: 13px;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.paper-submit-btn.buy {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: #fff;
}
.paper-submit-btn.sell {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #fff;
}
.paper-submit-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.paper-submit-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

/* ── P/L Chart ── */
.paper-chart-wrap {
    width: 100%;
    height: 280px;
    border-radius: 10px;
    overflow: hidden;
}
@media (max-width: 600px) {
    .paper-chart-wrap { height: 220px; }
}

/* Period tabs */
.paper-period-tabs {
    display: flex;
    gap: 4px;
}
.paper-period-btn {
    padding: 5px 12px;
    border: 1px solid var(--border-color, rgba(255,255,255,0.08));
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted, #94a3b8);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}
.paper-period-btn.active, .paper-period-btn:hover {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.3);
    color: #f59e0b;
}

/* ── Holdings Table ── */
.paper-holdings-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.paper-holdings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.paper-holdings-table th {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted, #94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.06));
    white-space: nowrap;
}
.paper-holdings-table th:last-child,
.paper-holdings-table td:last-child {
    text-align: right;
}
.paper-holdings-table td {
    padding: 10px;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.04));
    color: var(--text-primary, #fff);
    white-space: nowrap;
}
.paper-holdings-table tbody tr:hover {
    background: rgba(255,255,255,0.02);
}
.holding-code {
    font-weight: 700;
    color: #f59e0b;
}
.holding-positive { color: #22c55e; }
.holding-negative { color: #ef4444; }

/* ── Trade History ── */
.paper-history-list {
    max-height: 360px;
    overflow-y: auto;
}
.paper-history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.04));
}
.paper-history-item:last-child { border-bottom: none; }
.paper-history-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 12px; font-weight: 700;
}
.paper-history-icon.buy  { background: rgba(34,197,94,0.12); color: #22c55e; }
.paper-history-icon.sell { background: rgba(239,68,68,0.12); color: #ef4444; }
.paper-history-info { flex: 1; min-width: 0; }
.paper-history-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #fff);
}
.paper-history-sub {
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
    margin-top: 2px;
}
.paper-history-val {
    text-align: right;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}
.paper-history-val.buy  { color: #22c55e; }
.paper-history-val.sell { color: #ef4444; }
.paper-history-date {
    font-size: 10px;
    color: var(--text-muted, #64748b);
    text-align: right;
    margin-top: 2px;
}

/* ── Empty State ── */
.paper-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted, #94a3b8);
}
.paper-empty svg {
    width: 48px; height: 48px;
    color: var(--text-muted, #64748b);
    margin-bottom: 12px;
}
.paper-empty h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary, #cbd5e1);
    margin: 0 0 4px;
}
.paper-empty p {
    font-size: 12px;
    margin: 0;
}

/* ── Reset Button ── */
.paper-reset-btn {
    padding: 7px 14px;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    background: rgba(239, 68, 68, 0.08);
    color: #ef4444;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s;
}
.paper-reset-btn:hover {
    background: rgba(239, 68, 68, 0.15);
}

/* ── Toast ── */
.paper-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #f59e0b;
    color: #000;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
}
.paper-toast.active {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── Loading spinner ── */
.paper-spinner {
    width: 28px; height: 28px;
    border: 3px solid rgba(245, 158, 11, 0.15);
    border-top-color: #f59e0b;
    border-radius: 50%;
    animation: paperSpin 0.8s linear infinite;
    margin: 0 auto;
}
@keyframes paperSpin { to { transform: rotate(360deg); } }

/* ── Responsive ── */
@media (max-width: 600px) {
    .paper-trade-form { grid-template-columns: 1fr; }
    .paper-stats { grid-template-columns: 1fr 1fr; }
    .paper-stat-value { font-size: 17px; }
    .paper-section { padding: 12px; }
    .paper-header { padding: 16px 0 8px; }
    .paper-title { font-size: 17px; }
}
@media (max-width: 380px) {
    .paper-stats { grid-template-columns: 1fr; }
}

/* ── Topbar Paper Mode Toggle ── */
.paper-mode-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 20px;
    background: rgba(245, 158, 11, 0.08);
    color: #f59e0b;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}
.paper-mode-toggle:hover {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.5);
}
.paper-mode-toggle svg { width: 12px; height: 12px; }

/* Leaderboard */
.paper-leaderboard {
    list-style: none;
    margin: 0; padding: 0;
}
.paper-lb-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.04));
}
.paper-lb-item:last-child { border-bottom: none; }
.paper-lb-rank {
    width: 28px; height: 28px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 800;
    background: var(--bg-card, #0f172a);
    color: var(--text-muted, #94a3b8);
    flex-shrink: 0;
}
.paper-lb-item:nth-child(1) .paper-lb-rank { background: rgba(245,158,11,0.15); color: #f59e0b; }
.paper-lb-item:nth-child(2) .paper-lb-rank { background: rgba(148,163,184,0.15); color: #94a3b8; }
.paper-lb-item:nth-child(3) .paper-lb-rank { background: rgba(180,83,9,0.15); color: #b45309; }
.paper-lb-name {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #fff);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.paper-lb-return {
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}
.paper-lb-return.positive { color: #22c55e; }
.paper-lb-return.negative { color: #ef4444; }
