/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    /*max-width: 1200px;*/
    margin: 0 auto;
}

/* Header Styles */
header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1rem;
    opacity: 0.9;
}

/* Search Section */
.search-section {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

#searchInput {
    width: 100%;
    padding: 15px 20px;
    font-size: 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    outline: none;
    transition: border-color 0.3s ease;
}

#searchInput:focus {
    border-color: #667eea;
}

.filter-group {
    margin-top: 15px;
}

.filter-label {
    font-weight: bold;
    color: #666;
    margin-right: 10px;
    font-size: 0.9rem;
}

.filter-buttons {
    display: inline-flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 25px;
    background: #f0f0f0;
    color: #333;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-btn:hover {
    background: #e0e0e0;
}

.filter-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

/* Status filter button colors */
.filter-btn.status-owned.active {
    background: #22c55e;
}

.filter-btn.status-restock.active {
    background: #f59e0b;
}

.filter-btn.status-buy.active {
    background: #ef4444;
}

/* Type filter button colors */
.filter-btn.type-paint.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.filter-btn.type-thinner.active {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
}

.filter-btn.type-cleaner.active {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
}

.filter-btn.type-varnish.active {
    background: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%);
}

.filter-btn.type-other.active {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
}

/* Stats Section */
.stats-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: white;
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.stat-card.stat-owned {
    border-left: 4px solid #22c55e;
}

.stat-card.stat-restock {
    border-left: 4px solid #f59e0b;
}

.stat-card.stat-buy {
    border-left: 4px solid #ef4444;
}

.stat-number {
    display: block;
    font-size: 2rem;
    font-weight: bold;
    color: #667eea;
}

.stat-label {
    display: block;
    font-size: 0.8rem;
    color: #888;
    margin-top: 5px;
}

/* Color Grid */
.color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

/* Color Card */
.color-card {
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.color-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
}

.color-preview {
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.color-preview .preview-content {
    display: flex;
    align-items: center;
    justify-content: center;
}

.color-preview.non-paint-preview .preview-content {
    flex-direction: column;
    gap: 4px;
}

.color-preview .type-icon {
    font-size: 1.5rem;
}

.color-preview .type-number {
    font-size: 1rem;
}

.color-preview::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.1));
}

.color-info {
    padding: 20px;
}

.brand-tag {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: bold;
    margin-bottom: 10px;
}

.brand-tag.mr-color {
    background: #e3f2fd;
    color: #1976d2;
}

.brand-tag.vallejo {
    background: #fce4ec;
    color: #c2185b;
}

.color-name {
    font-size: 1.1rem;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.color-number {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 10px;
}

.color-hex {
    font-size: 0.8rem;
    color: #999;
    font-family: 'Courier New', monospace;
    background: #f5f5f5;
    padding: 5px 10px;
    border-radius: 5px;
    display: inline-block;
}

/* Tags Row */
.tags-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

/* Status Tag Styles */
.status-tag {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: bold;
    margin-bottom: 10px;
}

.status-tag.status-owned {
    background: #dcfce7;
    color: #16a34a;
}

.status-tag.status-restock {
    background: #fef3c7;
    color: #d97706;
}

.status-tag.status-buy {
    background: #fee2e2;
    color: #dc2626;
}

/* Type Tag Styles */
.type-tag {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: bold;
    margin-bottom: 10px;
}

.type-tag.type-paint {
    background: #ede9fe;
    color: #7c3aed;
}

.type-tag.type-thinner {
    background: #dbeafe;
    color: #1d4ed8;
}

.type-tag.type-cleaner {
    background: #cffafe;
    color: #0891b2;
}

.type-tag.type-varnish {
    background: #f3e8ff;
    color: #9333ea;
}

.type-tag.type-other {
    background: #f3f4f6;
    color: #4b5563;
}

/* Type Stats Card Styles */
.stat-card.stat-paint {
    border-left: 4px solid #7c3aed;
}

.stat-card.stat-thinner {
    border-left: 4px solid #1d4ed8;
}

.stat-card.stat-cleaner {
    border-left: 4px solid #0891b2;
}

.stat-card.stat-varnish {
    border-left: 4px solid #9333ea;
}

.stat-card.stat-other {
    border-left: 4px solid #4b5563;
}

/* Quantity Badge */
.quantity-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.85rem;
    font-weight: bold;
    z-index: 1;
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 8px;
    border-radius: 10px;
}

/* Color Details Row */
.color-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.color-quantity {
    font-size: 0.8rem;
    color: #666;
    font-weight: 500;
}

/* Footer */
footer {
    text-align: center;
    color: white;
    opacity: 0.8;
    font-size: 0.9rem;
}

/* Mobile Responsive */
@media (max-width: 992px) {
    .stats-section {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    body {
        padding: 15px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    .stats-section {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }

    .stat-card {
        padding: 15px 10px;
    }

    .stat-number {
        font-size: 1.5rem;
    }

    .stat-label {
        font-size: 0.7rem;
    }

    .color-grid {
        grid-template-columns: 1fr;
    }

    .filter-group {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
    }

    .filter-label {
        margin-bottom: 8px;
    }

    .filter-buttons {
        justify-content: flex-start;
    }

    .filter-btn {
        padding: 8px 15px;
        font-size: 0.85rem;
    }

    .color-chtname {
        font-size: 0.95rem;
        text-decoration: underline #ff3028;
        text-decoration-thickness: 2px;
        text-underline-offset: 3px;
    }
}

@media (max-width: 500px) {
    .stats-section {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 400px) {
    .stats-section {
        grid-template-columns: 1fr;
    }
}

/* Loading State */
.loading {
    text-align: center;
    padding: 50px;
    color: white;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

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

/* No Results */
.no-results {
    background: white;
    border-radius: 15px;
    padding: 50px;
    text-align: center;
    grid-column: 1 / -1;
}

.no-results h3 {
    color: #666;
    margin-bottom: 10px;
}

.no-results p {
    color: #999;
}

.type-tag.type-enhancer {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
}

.type-tag.type-protector {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
}

.type-tag.type-primer {
    background: linear-gradient(135deg, #9ca3af, #6b7280);
    color: #fff;
}

.color-filter-group .filter-buttons input[type="color"] {
    width: 40px;
    height: 34px;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 6px;
}

.color-filter-group #clearColorFilter {
    background: #f3f4f6;
    border: none;
}

/* 新增：美化簡潔型 bookmarks（不使用卡片樣式） */
.bookmarks {
    /* 若 index.html 有 inline style，這裡仍會補強其他視覺細節 */
    display: block;
    text-align: center;
    margin: 12px 0 6px;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.6;
    word-break: keep-all;
}

/* 連結樣式：淡色、無底線、微圓角 */
.bookmarks a {
    color: rgba(255, 255, 255, 0.95);
    text-decoration: none;
    padding: 6px 8px;
    border-radius: 6px;
    transition: background 160ms ease, color 160ms ease, transform 120ms ease;
    display: inline-block;
}

/* 懸停/焦點效果：輕微背景與底線 */
.bookmarks a:hover,
.bookmarks a:focus {
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
    transform: translateY(-1px);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1.6px;
}

/* 在連結之間顯示柔和分隔符（最後一項不顯示） */
.bookmarks a::after {
    content: "|";
    margin: 0 8px;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 600;
}

/* 移除最後一個分隔符 */
.bookmarks a:last-child::after {
    content: "";
    margin: 0;
}

/* 在小螢幕上允許換行並置中 */
@media (max-width: 600px) {
    .bookmarks {
        font-size: 0.9rem;
        text-align: center;
    }

    .bookmarks a {
        padding: 6px 6px;
        margin: 4px 2px;
    }

    .bookmarks a::after {
        display: none; /* 手機上移除分隔符，避免雜亂 */
    }
}

/* Description Button */
.description-btn {
    display: inline-block;
    margin-top: 12px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.description-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.description-btn:active {
    transform: translateY(0);
}


/* ===== 視圖切換 Tab ===== */

.view-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
}

.view-tab {
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.view-tab:hover {
    background: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.view-tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

/* ===== 色票檢視網格 ===== */

.palette-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 8px;
    margin-bottom: 30px;
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.palette-swatch {
    aspect-ratio: 1;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    position: relative;
    overflow: hidden;
}

.palette-swatch:hover {
    transform: scale(1.15);
    z-index: 10;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.palette-swatch .swatch-number {
    font-size: 0.65rem;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.palette-swatch:hover .swatch-number {
    opacity: 1;
}

/* Scroll to Top Button */
.scroll-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    z-index: 1000;
}

.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.scroll-to-top:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.scroll-to-top:active {
    transform: translateY(0);
}


/* ===== 顏色詳情彈窗 ===== */
.color-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: 20px;
    overflow-y: auto;
}

/* Dialog Overlay */
.dialog-overlay.active {
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.color-modal.active {
    opacity: 1;
    visibility: visible;
}

/* Dialog Overlay */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: 20px;
    overflow-y: auto;
}

.dialog-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Dialog Content */
.dialog-content {
    background: white;
    border-radius: 20px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.dialog-overlay.active .dialog-content {
    transform: scale(1);
}

/* Dialog Close Button */
.dialog-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 36px;
    height: 36px;
    background: #f0f0f0;
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: #666;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.dialog-close:hover {
    background: #e0e0e0;
    color: #333;
}

/* Dialog Title */
.dialog-title {
    padding: 25px 60px 15px 25px;
    margin: 0;
    font-size: 1.3rem;
    color: #333;
    border-bottom: 1px solid #eee;
}

/* Dialog Body */
.dialog-body {
    padding: 20px 25px 25px;
}

/* Dialog Description */
.dialog-description {
    font-size: 1rem;
    line-height: 1.7;
    color: #555;
    margin: 0 0 20px;
}

/* Dialog Images */
.dialog-images {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.dialog-image-item {
    width: 100%;
    border-radius: 10px;
    overflow: hidden;
    background: #f5f5f5;
}

.dialog-image-item img {
    width: 100%;
    height: auto;
    display: block;
}

/* Mobile responsive for dialog */
@media (max-width: 768px) {
    .dialog-overlay {
        padding: 10px;
        align-items: flex-start;
        padding-top: 40px;
    }

    .dialog-content {
        max-height: calc(100vh - 80px);
        border-radius: 15px;
    }

    .dialog-title {
        font-size: 1.15rem;
        padding: 20px 50px 12px 20px;
    }

    .dialog-body {
        padding: 15px 20px 20px;
    }

    .dialog-description {
        font-size: 0.95rem;
        line-height: 1.6;
    }

    .dialog-close {
        top: 12px;
        right: 12px;
    }
}

.color-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1;
}

.color-modal-content {
    position: relative;
    max-width: 400px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    z-index: 2;
}

.color-modal.active .color-modal-content {
    transform: scale(1);
}

.color-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}

.color-modal-close:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.1);
}

/* 彈窗內的卡片樣式調整 */
.color-modal-content .color-card {
    margin: 0;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

/* 手機端色票網格調整 */
@media (max-width: 768px) {
    .palette-grid {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
        gap: 6px;
        padding: 15px;
    }

    .view-tabs {
        flex-wrap: wrap;
    }

    .view-tab {
        padding: 10px 18px;
        font-size: 0.9rem;
    }

    .color-modal-content {
        width: 95%;
    }

    .color-modal-close {
        top: 8px;
        right: 8px;
        width: 32px;
        height: 32px;
        font-size: 1.3rem;
    }

    .description-btn {
        width: 100%;
        padding: 10px 16px;
        font-size: 0.9rem;
    }
}

@media (max-width: 768px) {
    .scroll-to-top {
        bottom: 20px;
        right: 20px;
        width: 45px;
        height: 45px;
        font-size: 1.3rem;
    }
}
