/* Toss-style Clean Design */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;500;600;700&display=swap');

:root, [data-theme="light"] {
    --bg-primary: #f5f6f8;
    --bg-card: #ffffff;
    --bg-input: #f0f1f4;
    --text-primary: #191f28;
    --text-secondary: #4e5968;
    --text-tertiary: #6b7684;
    --accent: #3182f6;
    --accent-light: #e8f3ff;
    --border: #e5e8eb;
    --positive: #f04452;
    --negative: #3182f6;
    --shadow: 0 2px 8px rgba(0,0,0,0.04);
    --shadow-hover: 0 4px 16px rgba(0,0,0,0.08);
    --radius: 16px;
    --radius-sm: 10px;
    --price-high: #f04452;
    --price-low: #3182f6;
    --opts-bg: #eef1f6;
    --opts-text: #333d4b;
}

[data-theme="dark"] {
    --bg-primary: #17171c;
    --bg-card: #21212a;
    --bg-input: #2c2c36;
    --text-primary: #ececec;
    --text-secondary: #b0b8c1;
    --text-tertiary: #8b95a1;
    --accent: #4e96f7;
    --accent-light: #1e2a3a;
    --border: #35353f;
    --positive: #f04452;
    --negative: #4e96f7;
    --shadow: 0 2px 8px rgba(0,0,0,0.2);
    --shadow-hover: 0 4px 16px rgba(0,0,0,0.3);
    --price-high: #ff6b6b;
    --price-low: #6bb5ff;
    --opts-bg: #2c2c36;
    --opts-text: #d0d5dc;
}

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

body {
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Header */
.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
}

.logo span {
    color: var(--accent);
}

.nav-links {
    display: flex;
    gap: 8px;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 8px;
    transition: all 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--accent);
    background: var(--accent-light);
}

/* 햄버거 메뉴 */
.hamburger-btn {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-primary);
    padding: 4px;
}
.nav-links .nav-mobile-only { display: none; }

@media (max-width: 720px) {
    .nav-links a { display: none; }
    .nav-links a.nav-show-mobile { display: inline-block; font-size: 13px; padding: 4px 8px; }
    .nav-links .theme-toggle.nav-show-mobile { display: inline-block !important; }
    .nav-links .theme-toggle:not(.nav-show-mobile) { display: none; }
    .hamburger-btn { display: block; }

    .nav-links.mobile-open {
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: var(--bg-card);
        z-index: 999;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
    }
    .nav-links.mobile-open a { display: block !important; font-size: 18px; padding: 14px 40px; text-align: center; width: 100%; }
    .nav-links.mobile-open .theme-toggle { display: block !important; margin-top: 12px; font-size: 24px; }
    .nav-links.mobile-open .nav-mobile-only { display: block !important; }
    .nav-links.mobile-open .nav-close {
        position: absolute;
        top: 16px; right: 20px;
        font-size: 28px;
        background: none;
        border: none;
        color: var(--text-primary);
        cursor: pointer;
    }
}

/* Container */
.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 24px 20px;
}

/* Search */
.search-section {
    margin-bottom: 24px;
}

.search-box {
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 16px 20px 16px 48px;
    font-size: 16px;
    font-family: inherit;
    border: none;
    border-radius: var(--radius);
    background: var(--bg-card);
    box-shadow: var(--shadow);
    outline: none;
    transition: box-shadow 0.2s;
    color: var(--text-primary);
}

.search-box input::placeholder {
    color: var(--text-tertiary);
}

.search-box input:focus {
    box-shadow: var(--shadow-hover), 0 0 0 2px var(--accent);
}

.search-box .search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: 18px;
}

/* Stats Bar */
.stats-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    overflow-x: auto;
    padding: 2px 0;
}

.stat-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-card);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.2s;
    border: 1.5px solid transparent;
}

.stat-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.stat-chip.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.stat-chip .chip-icon {
    font-size: 14px;
}

/* Filter Tabs */
.filter-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filter-tab {
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.filter-tab:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.filter-tab.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* Item List */
.item-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.item-card {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 16px 18px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 14px;
}

.item-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-1px);
}

.item-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.item-icon img {
    max-width: 36px;
    max-height: 36px;
    image-rendering: pixelated;
}

.item-info {
    flex: 1;
    min-width: 0;
}

.item-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-meta {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.item-price {
    text-align: right;
    flex-shrink: 0;
}

.item-price .price-value {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.item-price .price-label {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

/* Detail Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    justify-content: center;
    align-items: flex-end;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 720px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 24px 20px;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.modal-header .item-name {
    font-size: 18px;
}

.modal-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.modal-stat {
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    padding: 14px;
    text-align: center;
}

.modal-stat .stat-label {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 4px;
}

.modal-stat .stat-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-stat .stat-value.price-high {
    color: var(--price-high);
}

.modal-stat .stat-value.price-low {
    color: var(--price-low);
}

/* Theme toggle */
.theme-toggle {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-input);
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.theme-toggle:hover {
    background: var(--border);
}

.modal-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* Trade History Table */
.trade-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.trade-row {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-primary);
    border-radius: 8px;
    font-size: 13px;
    gap: 12px;
}

.trade-row .trade-time {
    color: var(--text-secondary);
    width: 140px;
    flex-shrink: 0;
    font-weight: 500;
}

.trade-row .trade-qty {
    color: var(--text-primary);
    width: 60px;
    text-align: center;
    font-weight: 600;
}

.trade-row .trade-price {
    flex: 1;
    text-align: right;
    font-weight: 700;
    color: var(--text-primary);
    font-size: 14px;
}

.trade-opts-row {
    padding: 4px 16px 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.trade-opt-tag {
    display: inline-block;
    padding: 3px 8px;
    background: var(--opts-bg);
    color: var(--opts-text);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
}

/* Load More */
.load-more {
    display: block;
    width: 100%;
    padding: 14px;
    margin-top: 12px;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.load-more:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Sort Select */
.sort-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.result-count {
    font-size: 13px;
    color: var(--text-tertiary);
}

.sort-select {
    padding: 6px 12px;
    font-size: 13px;
    font-family: inherit;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    outline: none;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-tertiary);
    font-size: 14px;
}

.loading .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Format meso */
.meso {
    font-variant-numeric: tabular-nums;
}

/* Close button */
.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-input);
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

/* Filter inputs */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
}

/* Responsive */
@media (max-width: 480px) {
    .container {
        padding: 16px 12px;
    }
    .modal-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    .trade-row .trade-time {
        width: 100px;
        font-size: 11px;
    }
}
