/* ══════════════════════════════════════════════════════
   ADMIN PANEL STYLES
   ══════════════════════════════════════════════════════ */

.admin-screen {
    padding-bottom: 80px;
}

.admin-scroll {
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    padding: 16px;
}

.admin-section {
    background: var(--bg-secondary, #f5f5f7);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.admin-section h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 16px 0;
    color: var(--text-primary, #000);
}

/* Dashboard Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.stat-card {
    background: var(--bg-primary, #fff);
    border-radius: 10px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary, #666);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary, #000);
    margin-bottom: 4px;
}

.stat-detail {
    font-size: 12px;
    color: var(--text-secondary, #666);
}

/* Notifications — unified card style */
.admin-notifications {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.notification-item {
    background: var(--bg, #fff);
    border-radius: 8px;
    padding: 10px 12px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background 0.2s, opacity 0.2s;
    font-size: 13px;
    color: var(--text, #212121);
}
.notification-item:hover {
    background: var(--bg-hover, #f0f0f0);
}

/* Unread — blue left border */
.notification-item.unread {
    border-left-color: #2196f3;
    background: rgba(33, 150, 243, 0.04);
}

/* Priority overrides */
.notification-item.priority-high {
    border-left-color: #ff9800;
}
.notification-item.priority-critical {
    border-left-color: #f44336;
}

.notification-item.read {
    opacity: 0.65;
}

.notification-message {
    font-size: 13px;
    margin-bottom: 4px;
    line-height: 1.4;
    color: inherit;
}

.notification-time {
    font-size: 11px;
    color: var(--text-secondary, #999);
}

/* Notification type colors (light mode) */
.notification-item.type-report_delivered {
    border-left-color: #4caf50;
    background: rgba(76, 175, 80, 0.06);
}
.notification-item.type-order_error,
.notification-item.type-order_failed {
    border-left-color: #f44336;
    background: rgba(244, 67, 54, 0.06);
}
.notification-item.type-payment_received {
    border-left-color: #4caf50;
    background: rgba(76, 175, 80, 0.08);
}

/* ── Dark mode — notifications (MUST be after light mode) ── */
html.dark .notification-item {
    background: #1c1c1e !important;
    color: var(--text, #e8e8e8);
}
html.dark .notification-item:hover {
    background: #2c2c2e !important;
}
html.dark .notification-item.unread {
    border-left-color: #42a5f5;
    background: rgba(66, 165, 245, 0.08) !important;
}
html.dark .notification-item.priority-high {
    border-left-color: #ffa726;
}
html.dark .notification-item.priority-critical {
    border-left-color: #ef5350;
}
html.dark .notification-item.type-report_delivered {
    border-left-color: #66bb6a;
    background: rgba(102, 187, 106, 0.10) !important;
}
html.dark .notification-item.type-order_error,
html.dark .notification-item.type-order_failed {
    border-left-color: #ef5350;
    background: rgba(239, 83, 80, 0.10) !important;
}
html.dark .notification-item.type-payment_received {
    border-left-color: #66bb6a;
    background: rgba(102, 187, 106, 0.12) !important;
}
html.dark .notification-message {
    color: #fff !important;
}
html.dark .notification-time {
    color: #98989d !important;
}

/* Orders — card layout (mobile-first) */
.admin-orders-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.order-card-admin {
    background: var(--bg-primary, #fff);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 1px 3px var(--shadow, rgba(0,0,0,0.08));
    border-left: 4px solid var(--border, #e0e0e0);
}

.order-card-admin.status-delivered,
.order-card-admin.status-ready { border-left-color: #4CAF50; }
.order-card-admin.status-processing,
.order-card-admin.status-paid { border-left-color: #2196F3; }
.order-card-admin.status-pending_payment { border-left-color: #FF9800; }
.order-card-admin.status-awaiting_chat { border-left-color: #F44336; }
.order-card-admin.status-error,
.order-card-admin.status-failed,
.order-card-admin.status-cancelled { border-left-color: #9E9E9E; }

.oc-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.oc-price {
    font-weight: 700;
    font-size: 15px;
    margin-left: auto;
}

.oc-cad {
    font-family: monospace;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
    word-break: break-all;
}

.oc-meta {
    font-size: 12px;
    color: var(--text-secondary, #888);
    margin-bottom: 4px;
}

.oc-pay {
    font-family: monospace;
    font-size: 11px;
    color: #aaa;
    margin-bottom: 6px;
}

.oc-footer {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-secondary, #999);
    padding-top: 6px;
    border-top: 1px solid var(--border, #eee);
}

.oc-id {
    font-family: monospace;
    color: #bbb;
}

.total-info {
    font-size: 12px;
    color: var(--text-secondary, #666);
    text-align: right;
    margin-top: 4px;
}

/* Controls */
.admin-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.admin-input {
    flex: 1; min-width: 160px; padding: 8px 10px;
    border: 1px solid #ddd; border-radius: 8px; font-size: 14px;
    background: var(--bg-primary, #fff); color: var(--text-primary, #000);
}
.admin-select {
    padding: 8px 10px; border: 1px solid #ddd; border-radius: 8px;
    font-size: 14px; background: var(--bg-primary, #fff);
    color: var(--text-primary, #000); min-width: 120px;
}
.admin-btn {
    padding: 8px 14px; border: none; border-radius: 8px;
    font-size: 14px; background: #007aff; color: #fff; cursor: pointer;
}
.admin-btn:hover { background: #0056cc; }

/* Action buttons */
.action-btn { background: none; border: none; cursor: pointer; font-size: 18px; padding: 2px 6px; }
.deliver-btn:hover { color: #007aff; }
.detail-btn:hover { color: #ff9500; }

/* Status badge */
.status-badge {
    display: inline-block; padding: 2px 8px; border-radius: 4px;
    font-size: 12px; font-weight: 500;
}
.status-delivered, .status-ready { background: #e8f5e9; color: #2e7d32; }
.status-processing, .status-paid { background: #e3f2fd; color: #1565c0; }
.status-created, .status-pending_payment { background: #fff3e0; color: #e65100; }
.status-awaiting_chat { background: #fce4ec; color: #c62828; }
.status-error, .status-failed, .status-cancelled { background: #ffebee; color: #b71c1c; }

/* Alert cards */
.stat-card.alert { border-left: 3px solid transparent; transition: all 0.3s; }
.stat-card.alert-active { border-left-color: #ff3b30; background: rgba(255,59,48,0.05); }

/* Modal */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 1000;
    display: flex; align-items: center; justify-content: center;
}
.modal {
    background: var(--bg-primary, #fff); border-radius: 12px; padding: 24px;
    max-width: 90vw; max-height: 80vh; overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.modal h3 { margin: 0 0 16px; }
.modal p { font-size: 14px; line-height: 1.6; margin-bottom: 16px; }

/* Dark mode */
html.dark .admin-input, html.dark .admin-select { background: #2c2c2e; border-color: #555; color: #fff; }
html.dark .modal { background: #1c1c1e; color: #fff; }
html.dark .order-card-admin { background: #2c2c2e; }
html.dark .admin-section { background: #1c1c1e; }
html.dark .stat-card { background: #2c2c2e; }
html.dark .stat-label { color: #98989d; }
html.dark .stat-value { color: #fff; }
html.dark .stat-detail { color: #98989d; }
html.dark .order-card-admin { border-left-color: #555; }

/* Awaiting chat banner */
.awaiting-banner {
    background: linear-gradient(135deg, #ff6b35, #ff3b30);
    color: #fff;
    padding: 12px 16px;
    cursor: pointer;
    text-align: center;
}
.awaiting-banner-content {
    max-width: 600px;
    margin: 0 auto;
    font-size: 14px;
}
.awaiting-banner-content b {
    font-size: 16px;
}

/* Event feed */
.event-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    margin-bottom: 4px;
    border-radius: 6px;
    border-left: 3px solid transparent;
    background: var(--bg, #fff);
    color: var(--text, #212121);
    font-size: 13px;
    transition: background 0.15s;
}
.event-item:hover {
    background: var(--bg-hover, #f0f0f0);
}
.event-icon { font-size: 16px; flex-shrink: 0; width: 20px; text-align: center; }
.event-text { flex: 1; line-height: 1.4; color: inherit; }
.event-text code {
    font-family: 'SF Mono', 'Consolas', 'Menlo', monospace;
    font-size: 12px;
    background: rgba(128,128,128,0.12);
    padding: 1px 6px;
    border-radius: 3px;
}
.event-time {
    font-size: 11px;
    color: var(--text-secondary, #999);
    white-space: nowrap;
    flex-shrink: 0;
}

/* Event type colors — border + subtle background */
.event-delivered {
    border-left-color: #4caf50;
    background: rgba(76, 175, 80, 0.06);
    color: #2e7d32;
}
.event-pending {
    border-left-color: #ff9800;
    background: rgba(255, 152, 0, 0.06);
    color: #e65100;
}
.event-processing {
    border-left-color: #2196f3;
    background: rgba(33, 150, 243, 0.06);
    color: #1565c0;
}
.event-cancelled {
    border-left-color: #f44336;
    background: rgba(244, 67, 54, 0.06);
    color: #c62828;
}
.event-error {
    border-left-color: #d32f2f;
    background: rgba(211, 47, 47, 0.08);
    color: #b71c1c;
    font-weight: 600;
}
.event-info {
    border-left-color: #9e9e9e;
    color: #616161;
}

/* Dark mode — events */
html.dark .event-item {
    background: #1c1c1e !important;
    color: var(--text, #e8e8e8);
}
html.dark .event-item:hover {
    background: #2c2c2e !important;
}
html.dark .event-delivered {
    border-left-color: #66bb6a;
    background: rgba(102, 187, 106, 0.10) !important;
    color: #a5d6a7 !important;
}
html.dark .event-pending {
    border-left-color: #ffa726;
    background: rgba(255, 167, 38, 0.10) !important;
    color: #ffcc80 !important;
}
html.dark .event-processing {
    border-left-color: #42a5f5;
    background: rgba(66, 165, 245, 0.10) !important;
    color: #90caf9 !important;
}
html.dark .event-cancelled {
    border-left-color: #ef5350;
    background: rgba(239, 83, 80, 0.10) !important;
    color: #ef9a9a !important;
}
html.dark .event-error {
    border-left-color: #f44336;
    background: rgba(244, 67, 54, 0.12) !important;
    color: #ef9a9a !important;
}
html.dark .event-info {
    border-left-color: #757575;
    color: #bdbdbd !important;
}
html.dark .event-time {
    color: #98989d !important;
}
html.dark .event-text code {
    background: rgba(255,255,255,0.1);
}

.cancel-btn:hover { color: #c62828; }
.retry-btn:hover { color: #ff9500; }

/* Finance */
#finProfit { font-weight: 800; }
