/* ============================================================
   Tarkov Tracker — Stylesheet
   Dark military/tactical theme inspired by EFT
   ============================================================ */

:root {
    --bg-dark:       #1a1a1e;
    --bg-main:       #222226;
    --bg-card:       #2a2a2f;
    --bg-card-hover: #32323a;
    --bg-input:      #1e1e22;
    --bg-sidebar:    #16161a;

    --border:        #3a3a42;
    --border-light:  #2e2e36;

    --text:          #e4e4e8;
    --text-dim:      #9a9aa4;
    --text-muted:    #6a6a74;

    --accent:        #c8a84e;
    --accent-dim:    #a08030;
    --accent-bg:     rgba(200, 168, 78, 0.12);

    --green:         #4caf50;
    --green-bg:      rgba(76, 175, 80, 0.12);
    --green-dim:     #388e3c;

    --red:           #e05252;
    --red-bg:        rgba(224, 82, 82, 0.12);

    --blue:          #5b9bd5;
    --blue-bg:       rgba(91, 155, 213, 0.12);

    --orange:        #e0943a;
    --orange-bg:     rgba(224, 148, 58, 0.12);

    --radius:        6px;
    --radius-lg:     10px;

    --sidebar-w:     220px;
    --topbar-h:      56px;

    --font:          'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono:     'JetBrains Mono', 'Fira Code', monospace;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
    font-family: var(--font);
    background: var(--bg-dark);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--text); }
img { max-width: 100%; height: auto; }
button { cursor: pointer; font-family: inherit; }

/* ---- Layout ---- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform 0.25s ease;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border-light);
}
.brand-icon {
    width: 36px; height: 36px;
    background: var(--accent-bg);
    border: 1px solid var(--accent-dim);
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    color: var(--accent);
    font-size: 18px;
}
.brand-name { font-weight: 600; font-size: 15px; color: var(--text); }
.brand-sub  { font-size: 11px; color: var(--text-muted); }

.sidebar-nav {
    list-style: none;
    padding: 10px 8px;
    flex: 1;
}
.sidebar-nav li { margin-bottom: 2px; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius);
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
}
.sidebar-nav a i { font-size: 18px; }
.sidebar-nav a:hover { background: var(--bg-card); color: var(--text); }
.sidebar-nav a.active {
    background: var(--accent-bg);
    color: var(--accent);
    border: 1px solid rgba(200, 168, 78, 0.2);
}
.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border-light);
}
.sidebar-link-sm {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
    padding: 6px 10px;
    border-radius: var(--radius);
}
.sidebar-link-sm:hover { background: var(--bg-card); color: var(--text-dim); }

/* ---- Main ---- */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ---- Top Bar ---- */
.top-bar {
    height: var(--topbar-h);
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-main);
    position: sticky;
    top: 0;
    z-index: 50;
}
.page-title {
    font-size: 16px;
    font-weight: 600;
    flex: 1;
}
.top-bar-actions { display: flex; gap: 8px; }
.mobile-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 20px;
    padding: 4px;
}

/* ---- Content ---- */
.content-area {
    padding: 24px;
    flex: 1;
}

/* ---- Cards ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 16px;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.card-title {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
.card-title i { color: var(--accent); font-size: 18px; }

/* ---- Metrics Grid ---- */
.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.metric {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
}
.metric-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.metric-value { font-size: 24px; font-weight: 700; font-family: var(--font-mono); }
.metric-sub   { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ---- Tables ---- */
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: 10px;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
    vertical-align: middle;
}
.data-table tr:hover td { background: var(--bg-card-hover); }
.data-table tr:last-child td { border-bottom: none; }

/* ---- Item display ---- */
.item-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.item-icon {
    border-radius: 4px;
    background: var(--bg-input);
    object-fit: contain;
}
.item-icon-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    background: var(--bg-input);
    color: var(--text-muted);
    font-size: 18px;
}
.item-name { font-weight: 500; }
.item-short { color: var(--text-muted); font-size: 12px; }

/* ---- Badges ---- */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
}
.badge-fir     { background: var(--orange-bg); color: var(--orange); }
.badge-trader  { background: var(--blue-bg); color: var(--blue); }
.badge-active  { background: var(--accent-bg); color: var(--accent); }
.badge-completed, .badge-built { background: var(--green-bg); color: var(--green); }
.badge-locked  { background: rgba(106, 106, 116, 0.15); color: var(--text-muted); }
.badge-available { background: var(--blue-bg); color: var(--blue); }
.badge-building  { background: var(--orange-bg); color: var(--orange); }

/* ---- Progress Bar ---- */
.progress-bar {
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
    flex: 1;
}
.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}
.progress-accent { background: var(--accent); }
.progress-green  { background: var(--green); }
.progress-blue   { background: var(--blue); }
.progress-label  { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

.progress-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    transition: all 0.15s;
}
.btn:hover { background: var(--bg-card-hover); color: var(--text); }
.btn i { font-size: 16px; }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #1a1a1e;
}
.btn-primary:hover { background: var(--accent-dim); color: #1a1a1e; }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-sm i { font-size: 14px; }

.btn-success { background: var(--green-bg); border-color: var(--green-dim); color: var(--green); }
.btn-danger  { background: var(--red-bg); border-color: var(--red); color: var(--red); }

.btn-icon {
    padding: 6px;
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: 16px;
    border-radius: var(--radius);
}
.btn-icon:hover { background: var(--bg-card); color: var(--text); }

/* ---- Forms ---- */
.form-group { margin-bottom: 14px; }
.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 4px;
}
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-bg);
}
.form-input::placeholder { color: var(--text-muted); }
.form-textarea { resize: vertical; min-height: 80px; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-inline {
    display: flex;
    gap: 8px;
    align-items: end;
}

/* ---- Filters ---- */
.filter-bar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.filter-btn {
    padding: 5px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: none;
    color: var(--text-dim);
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
}
.filter-btn:hover { background: var(--bg-card); color: var(--text); }
.filter-btn.active {
    background: var(--accent-bg);
    border-color: var(--accent-dim);
    color: var(--accent);
}

/* ---- Flash Messages ---- */
.flash {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    margin: 16px 24px 0;
    border-radius: var(--radius);
    font-size: 13px;
}
.flash i { font-size: 18px; }
.flash-close {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    opacity: 0.6;
    font-size: 16px;
}
.flash-success { background: var(--green-bg); color: var(--green); }
.flash-error   { background: var(--red-bg); color: var(--red); }
.flash-info    { background: var(--blue-bg); color: var(--blue); }

/* ---- Hideout Grid ---- */
.hideout-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}
.hideout-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
}
.hideout-card.ready { border-color: var(--green-dim); }

.hideout-name {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.hideout-name i { color: var(--accent); font-size: 18px; }
.hideout-level { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.hideout-items { margin-top: 8px; }
.hideout-item-row {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
}
.hideout-item-row .ti-check { color: var(--green); }
.hideout-item-row .ti-x     { color: var(--red); }

/* ---- Shopping List ---- */
.shop-qty { font-family: var(--font-mono); font-weight: 600; }
.shop-have { color: var(--green); }
.shop-need { color: var(--red); }
.shop-done { color: var(--green); }
.shop-source {
    font-size: 11px;
    color: var(--text-muted);
    display: block;
    margin-top: 1px;
}

/* ---- Inline Quantity Controls ---- */
.qty-control {
    display: inline-flex;
    align-items: center;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.qty-control button {
    width: 28px;
    height: 28px;
    background: var(--bg-card);
    border: none;
    color: var(--text-dim);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.qty-control button:hover { background: var(--bg-card-hover); color: var(--text); }
.qty-control .qty-val {
    min-width: 32px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font-mono);
    background: var(--bg-input);
    padding: 4px 2px;
    border: none;
    color: var(--text);
}

/* ---- Modal ---- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 100%;
    max-width: 520px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
}
.modal-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.empty-state i { font-size: 48px; margin-bottom: 12px; display: block; }
.empty-state p { font-size: 14px; margin-bottom: 12px; }

/* ---- Player Level Badge ---- */
.player-level {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--accent-bg);
    border: 1px solid var(--accent-dim);
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--accent);
}
.player-level i { font-size: 14px; }

/* ---- Sidebar Player ---- */
.sidebar-player {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
}
.player-info {
    display: flex;
    align-items: center;
    gap: 8px;
}
.player-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-dim);
}

/* ---- Trader Grid (Settings) ---- */
.trader-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}
.trader-card {
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 12px 14px;
}
.trader-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.trader-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-card);
}
.trader-avatar-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 20px;
}
.trader-card-name {
    font-size: 14px;
    font-weight: 600;
}
.trader-card-level { margin-top: 2px; }
.trader-card-control { }

/* ---- Trader Level Dots ---- */
.trader-level-dots {
    display: inline-flex;
    gap: 3px;
}
.trader-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    display: inline-block;
}
.trader-dot.filled {
    background: var(--accent);
    border-color: var(--accent);
}

/* ---- Item Detail Modal ---- */
.modal-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    padding: 4px;
    border-radius: var(--radius);
    cursor: pointer;
}
.modal-close-btn:hover { color: var(--text); background: var(--bg-card-hover); }

.item-detail-link {
    cursor: pointer;
    transition: opacity 0.15s;
}
.item-detail-link:hover { opacity: 0.8; }

.item-detail-spinner {
    text-align: center;
    padding: 40px;
    color: var(--accent);
    font-size: 32px;
}
.item-detail-spinner i { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.id-header {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 16px;
}
.id-image {
    width: 120px;
    height: 120px;
    flex-shrink: 0;
    background: var(--bg-input);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid var(--border-light);
}
.id-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.id-info { flex: 1; min-width: 0; }
.id-name {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 2px;
    line-height: 1.3;
}
.id-short {
    font-size: 13px;
    color: var(--text-muted);
    display: block;
}
.id-meta {
    display: flex;
    gap: 14px;
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-dim);
}
.id-meta i { font-size: 14px; vertical-align: -1px; margin-right: 3px; }

.id-inventory {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}
.id-inv-box {
    background: var(--bg-input);
    border-radius: var(--radius);
    padding: 8px 10px;
    text-align: center;
}
.id-inv-label {
    font-size: 11px;
    color: var(--text-muted);
    display: block;
    margin-bottom: 2px;
}
.id-inv-val {
    font-size: 18px;
    font-weight: 700;
    font-family: var(--font-mono);
}

.id-usage { margin-top: 16px; }
.id-section-title {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
}
.id-section-title i { color: var(--accent); font-size: 16px; }
.id-usage-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 6px;
}
.id-usage-label i { font-size: 14px; }
.id-table td { padding: 5px 8px; font-size: 12px; }

.id-wiki-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 14px;
    font-size: 13px;
    color: var(--accent);
    padding: 6px 12px;
    background: var(--accent-bg);
    border-radius: var(--radius);
    border: 1px solid var(--accent-dim);
}
.id-wiki-link:hover { color: var(--text); background: var(--bg-card-hover); }

/* ---- Item Autocomplete ---- */
.item-autocomplete {
    position: relative;
    flex: 1;
}
.ac-search {
    width: 100%;
    padding: 6px 10px 6px 30px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 12px;
    font-family: inherit;
}
.ac-search:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-bg);
}
.ac-search-icon {
    position: absolute;
    left: 9px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 14px;
    pointer-events: none;
}
.ac-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 150;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 4px;
    max-height: 260px;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.ac-dropdown.open { display: block; }
.ac-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.1s;
}
.ac-row:hover, .ac-row.active { background: var(--bg-card-hover); }
.ac-icon {
    width: 28px; height: 28px;
    border-radius: 3px;
    background: var(--bg-input);
    object-fit: contain;
    flex-shrink: 0;
}
.ac-icon-ph {
    width: 28px; height: 28px;
    border-radius: 3px;
    background: var(--bg-input);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); font-size: 14px; flex-shrink: 0;
}
.ac-info { flex: 1; min-width: 0; }
.ac-name { font-weight: 500; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-short { color: var(--text-muted); font-size: 11px; }
.ac-qty { color: var(--text-muted); font-size: 11px; font-family: var(--font-mono); white-space: nowrap; }
.ac-empty { padding: 12px; text-align: center; color: var(--text-muted); font-size: 12px; }

/* ---- Level-Locked Quests ---- */
.quest-locked { opacity: 0.4; }
.quest-locked .card { border-style: dashed; }
.level-warning {
    font-size: 11px;
    color: var(--red);
    display: flex;
    align-items: center;
    gap: 4px;
}
.level-ok {
    font-size: 11px;
    color: var(--green);
}

/* ---- Shopping Quick-Add Row Highlight ---- */
.data-table tr.item-complete td { opacity: 0.4; }
.shop-missing.done { color: var(--green) !important; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .mobile-toggle { display: block; }
    .content-area { padding: 16px; }
    .metrics { grid-template-columns: 1fr 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .hideout-grid { grid-template-columns: 1fr; }
    .trader-grid { grid-template-columns: 1fr 1fr; }
    .sidebar-player { padding: 8px 12px; }
}
