/* The Fops Files — Dark MTG Theme */

:root {
    --bg: #0d0d16;
    --bg-card: #14141f;
    --bg-input: #1a1a2a;
    --bg-hover: #1e1e30;
    --border: #2a2a3a;
    --text: #d0d8e8;
    --text-dim: #8890a0;
    --text-bright: #ffffff;
    --gold: #d4a843;
    --gold-dim: #a08030;
    --cyan: #00e5ff;
    --green: #44cc66;
    --red: #ff4466;
    --orange: #ff8c00;
    /* MTG colors */
    --mtg-w: #f9faf4;
    --mtg-u: #0e68ab;
    --mtg-b: #150b00;
    --mtg-r: #d3202a;
    --mtg-g: #00733e;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, sans-serif;
    line-height: 1.5;
    min-height: 100vh;
}

/* ── Header ── */

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}

.header h1 {
    font-size: 20px;
    color: var(--gold);
    letter-spacing: 2px;
    font-weight: 700;
}

.header-actions {
    display: flex;
    gap: 12px;
}

.btn {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s;
}

.btn:hover { background: var(--bg-hover); border-color: var(--gold-dim); }
.btn-primary { background: var(--gold-dim); color: var(--text-bright); border-color: var(--gold); }
.btn-primary:hover { background: var(--gold); }
.btn-danger { border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red); color: white; }

/* ── Top Section (QR + Stats) ── */

.top-section {
    display: flex;
    gap: 24px;
    padding: 24px;
    border-bottom: 1px solid var(--border);
}

.qr-panel {
    flex-shrink: 0;
    text-align: center;
    padding: 16px;
    background: var(--bg-card);
    border-radius: 10px;
    border: 1px solid var(--border);
}

.qr-panel img {
    width: 160px;
    height: 160px;
    border-radius: 6px;
}

.qr-panel p {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 8px;
}

.stats-panel {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}

.stat-card .value {
    font-size: 28px;
    font-weight: 700;
    color: var(--gold);
}

.stat-card .label {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 4px;
}

/* ── Search & Filters ── */

.controls {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    align-items: center;
}

.search-input {
    flex: 1;
    min-width: 200px;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 14px;
    outline: none;
}

.search-input:focus { border-color: var(--gold-dim); }
.search-input::placeholder { color: var(--text-dim); }

select {
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    outline: none;
    cursor: pointer;
}

select:focus { border-color: var(--gold-dim); }

/* ── Collection Table ── */

.table-container {
    padding: 0 24px 24px;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th {
    text-align: left;
    padding: 12px 10px;
    color: var(--text-dim);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

th:hover { color: var(--gold); }
th.sorted { color: var(--gold); }
th .arrow { font-size: 10px; margin-left: 4px; }

td {
    padding: 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tr:hover { background: var(--bg-hover); }

.card-name {
    color: var(--text-bright);
    font-weight: 600;
    cursor: pointer;
}

.card-name:hover { color: var(--gold); }

.card-set { color: var(--text-dim); font-size: 12px; }
.card-price { color: var(--green); font-weight: 600; }
.card-foil { color: var(--cyan); }

.rarity-common { color: #888; }
.rarity-uncommon { color: #c0c0c0; }
.rarity-rare { color: var(--gold); }
.rarity-mythic { color: var(--orange); }

/* Quantity controls */
.qty-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.qty-btn {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qty-btn:hover { border-color: var(--gold-dim); }

/* ── Card Detail Expand ── */

.card-detail {
    display: none;
    padding: 16px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.card-detail.open { display: flex; gap: 20px; }

.card-detail img {
    width: 200px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.card-detail-info { flex: 1; }
.card-detail-info h3 { color: var(--text-bright); margin-bottom: 8px; }
.card-detail-info .type { color: var(--text-dim); margin-bottom: 12px; }
.card-detail-info .oracle { white-space: pre-wrap; font-size: 13px; margin-bottom: 16px; }

.detail-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* ── Empty State ── */

.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-dim);
}

.empty-state h2 { color: var(--gold); margin-bottom: 8px; }

/* ── Toast Notifications ── */

.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--green);
    color: var(--text);
    padding: 12px 20px;
    border-radius: 8px;
    margin-top: 8px;
    font-size: 13px;
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.5s forwards;
}

@keyframes slideIn { from { transform: translateX(100px); opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(10px); } }

/* ════════════════════════════════
   MOBILE STYLES
   ════════════════════════════════ */

@media (max-width: 768px) {
    .top-section { flex-direction: column; padding: 16px; }
    .qr-panel { display: none; }
    .controls { padding: 12px 16px; }
    .table-container { padding: 0 16px 16px; }
    .header { padding: 12px 16px; }
    .stat-card .value { font-size: 22px; }
}

/* ── Mobile Scanner Page ── */

.mobile-app {
    max-width: 500px;
    margin: 0 auto;
    padding: 16px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.mobile-header {
    text-align: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

.mobile-header h1 {
    font-size: 18px;
    color: var(--gold);
    letter-spacing: 2px;
}

.mobile-header p { font-size: 12px; color: var(--text-dim); }

.mobile-search {
    position: relative;
    margin-bottom: 16px;
}

.mobile-search input {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    outline: none;
}

.mobile-search input:focus { border-color: var(--gold); }

.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0 0 10px 10px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.autocomplete-list.visible { display: block; }

.autocomplete-item {
    padding: 12px 16px;
    cursor: pointer;
    font-size: 15px;
    border-bottom: 1px solid var(--border);
}

.autocomplete-item:hover, .autocomplete-item.selected {
    background: var(--bg-hover);
    color: var(--gold);
}

/* Card Preview */
.card-preview {
    display: none;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.card-preview.visible { display: block; }

.card-preview-content {
    display: flex;
    gap: 16px;
}

.card-preview img {
    width: 140px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

.card-preview-info { flex: 1; }
.card-preview-info h3 { font-size: 16px; color: var(--text-bright); margin-bottom: 4px; }
.card-preview-info .set { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }
.card-preview-info .price { font-size: 18px; color: var(--green); font-weight: 700; }
.card-preview-info .type { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

.prints-selector {
    margin-top: 12px;
}

.prints-selector select {
    width: 100%;
    padding: 10px;
    font-size: 14px;
}

/* Add Controls */
.add-controls {
    display: none;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.add-controls.visible { display: block; }

.add-row {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    align-items: center;
}

.add-row label {
    font-size: 13px;
    color: var(--text-dim);
    min-width: 70px;
}

.add-row select, .add-row input {
    flex: 1;
}

.add-btn {
    width: 100%;
    padding: 16px;
    font-size: 18px;
    font-weight: 700;
    background: var(--gold-dim);
    color: var(--text-bright);
    border: 2px solid var(--gold);
    border-radius: 10px;
    cursor: pointer;
    letter-spacing: 1px;
}

.add-btn:hover { background: var(--gold); }
.add-btn:active { transform: scale(0.98); }

/* Recent Adds */
.recent-adds {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

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

.recent-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}

.recent-item .name { color: var(--text-bright); }
.recent-item .meta { color: var(--text-dim); }

/* Mobile toast */
.mobile-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--green);
    color: var(--bg);
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 14px;
    z-index: 1000;
    animation: slideDown 0.3s ease, fadeOut 0.3s ease 2s forwards;
}

@keyframes slideDown { from { transform: translate(-50%, -50px); opacity: 0; } }
