:root {
    --bg-color: #ffffff;
    --text-color: #333333;
    --header-bg: #f8f9fa;
    --border-color: #e9ecef;
    --accent-color: #007bff;
    --secondary-text: #6c757d;
    --item-hover-bg: #f1f3f5;
    --source-badge-bg: #f1f3f5;
    --source-badge-text: #868e96;
}

[data-theme="dark"] {
    --bg-color: #121212;
    --text-color: #e0e0e0;
    --header-bg: #1e1e1e;
    --border-color: #333333;
    --accent-color: #4dabf7;
    --secondary-text: #adb5bd;
    --item-hover-bg: #2c2c2c;
    --source-badge-bg: #2c2c2c;
    --source-badge-text: #adb5bd;
}

body {
    font-family: 'Inter', 'Noto Sans KR', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    transition: background-color 0.3s, color 0.3s;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 16px;
}

/* Header */
.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.site-logo {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

.site-logo a {
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.3s;
}

.site-logo a:hover {
    color: var(--accent-color);
}

.header-right {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px;
    border-radius: 50%;
    transition: background-color 0.2s;
    color: var(--text-color);
}

.btn-icon:hover {
    background-color: var(--item-hover-bg);
}

[data-theme="dark"] .icon-sun {
    display: inline;
}

[data-theme="dark"] .icon-moon {
    display: none;
}

[data-theme="light"] .icon-sun {
    display: none;
    flex-direction: column;
    gap: 12px;
}

.deal-item {
    display: flex;
    flex-direction: column;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-color);
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
    color: inherit;
}

.deal-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    background-color: var(--item-hover-bg);
}

.deal-main {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    /* Prevent flex item from overflowing */
    margin-bottom: 8px;
    /* Spacing for mobile column layout */
}

.deal-source {
    font-size: 0.75rem;
    color: var(--text-color);
    line-height: 1.4;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 600px) {
    .deal-title {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: normal;
        min-height: 2.8em;
        max-height: 2.8em;
    }
}

.deal-title a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s;
}

.deal-title a:hover {
    color: var(--accent-color);
}

/* Visited Link Style */
.deal-item.visited {
    opacity: 0.6;
}

.deal-item.visited .deal-title a {
    color: #888;
}

/* Search Box */
.search-box {
    margin-right: 10px;
}

#search-input {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

#search-input:focus {
    border-color: var(--accent-color);
}

.deal-price,
.deal-time {
    font-size: 0.8rem;
    color: #999;
    font-weight: 400;
    white-space: nowrap;
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--secondary-text);
}

.no-deals {
    text-align: center;
    padding: 40px;
    color: var(--secondary-text);
}

.error {
    text-align: center;
    padding: 40px;
    color: #dc3545;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 30px;
    padding-bottom: 20px;
}

.pagination button {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    color: var(--text-color);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.pagination button:hover:not(:disabled) {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination .page-info {
    display: flex;
    align-items: center;
    font-weight: 500;
}

/* Footer */
.site-footer {
    margin-top: 40px;
    padding: 20px 0;
    text-align: center;
    color: var(--secondary-text);
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color);
}

/* Responsive */
@media (min-width: 600px) {
    .deal-item {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .deal-main {
        margin-bottom: 0;
    }

    .deal-meta {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        min-width: 100px;
        margin-left: 16px;
    }

    .deal-price {
        margin-bottom: 4px;
    }
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .site-header {
        flex-wrap: wrap;
        gap: 10px;
    }

    .header-left {
        width: 100%;
        text-align: center;
        margin-bottom: 5px;
    }

    .header-right {
        width: 100%;
        justify-content: center;
    }

    .search-box {
        flex-grow: 1;
    }

    #search-input {
        width: 100%;
        box-sizing: border-box;
    }
}

/* Tab Styles */
.tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    padding: 10px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
    opacity: 0.6;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    opacity: 1;
    background-color: rgba(0,0,0,0.05);
}

.tab-btn.active {
    opacity: 1;
    border-bottom: 2px solid var(--accent-color);
    color: var(--accent-color);
    margin-bottom: -2px; /* Overlap border */
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}