/* Google Trends Viewer - Calculator-specific CSS */
/* Only calculator-specific styles, DO NOT redefine global classes */

/* ========== Country Tabs ========== */
.trends-country-tabs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.trends-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    color: #64748b;
}

.trends-tab:hover {
    border-color: #667eea;
    color: #667eea;
}

.trends-tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-color: transparent;
}

.trends-flag {
    font-size: 1.5rem;
}

/* ========== Source Tabs (Google/YouTube/Wikipedia) ========== */
.trends-source-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;  /* All screen sizes: 1fr 1fr 1fr */
    gap: 8px;  /* 減少間距從 10px -> 8px */
    margin-bottom: 15px;  /* 增加與下方內容的距離 */
}

.trends-source-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;  /* 減少圖標與文字間距從 8px -> 6px */
    padding: 10px 12px;  /* 減少 padding 從 12px 20px -> 10px 12px */
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    color: #64748b;
    font-size: 0.9rem;  /* 減少字體大小 */
    min-width: 0;  /* 允許彈性收縮 */
}

.trends-source-tab:hover {
    border-color: #667eea;
    color: #667eea;
}

.trends-source-tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-color: transparent;
}

.trends-source-tab i {
    font-size: 1.2rem;
}

/* ========== Translation Control ========== */
.compact-select {
    padding: 10px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    color: #64748b;
    min-width: 120px;
}

.compact-select:hover {
    border-color: #667eea;
}

.compact-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Hide Google Translate banner */
.goog-te-banner-frame {
    display: none !important;
}

body {
    top: 0 !important;
}

/* Hide the default Google Translate widget but keep it in DOM for combo to render */
#google_translate_element {
    position: fixed;
    top: 0;
    left: 0;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    z-index: -9999;
}

/* ========== Date Selector ========== */
.trends-date-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.trends-date-btn {
    flex: 1;
    min-width: calc(50% - 4px);
    padding: 10px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.trends-date-btn:hover {
    border-color: #667eea;
    background: #f8fafc;
}

.trends-date-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-color: transparent;
}

.trends-date-btn .date-main {
    font-weight: 600;
    font-size: 0.95rem;
}

.trends-date-btn .date-weekday {
    font-size: 0.8rem;
    opacity: 0.8;
}

/* ========== Info Section ========== */
.trends-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.trends-info .info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #e2e8f0;
}

.trends-info .info-row:last-child {
    border-bottom: none;
}

.trends-info .info-label {
    color: #64748b;
    font-size: 0.9rem;
}

.trends-info .info-value {
    color: #1e293b;
    font-weight: 500;
    font-size: 0.9rem;
}

/* ========== Trends List ========== */
.trends-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.trends-badge {
    padding: 4px 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

/* ========== Country Navigation ========== */
.country-nav-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.country-nav-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #fff;
    font-size: 0.75rem;
}

.country-nav-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}

.country-nav-btn:active {
    transform: scale(0.95);
}

/* ========== Date Navigation ========== */
.trends-date-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}

.trends-date-display {
    color: #64748b;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.date-nav-btn {
    background: rgba(102, 126, 234, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #667eea;
}

.date-nav-btn:hover:not(:disabled) {
    background: rgba(102, 126, 234, 0.2);
    border-color: #667eea;
    transform: scale(1.05);
}

.date-nav-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.date-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ========== Refresh Button ========== */
.btn-refresh {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.btn-refresh:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-refresh:active {
    transform: translateY(0);
}

.btn-refresh i {
    transition: transform 0.6s ease;
}

.btn-refresh:active i {
    transform: rotate(360deg);
}

.trends-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: #f8fafc;
    border-radius: 12px;
    transition: all 0.3s ease;
    text-decoration: none;
    color: inherit;
}

.trends-item:hover {
    background: #e2e8f0;
    transform: translateX(5px);
}

.trends-rank {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

/* Rank colors */
.trends-rank.rank-1 {
    background: linear-gradient(135deg, #ffd700 0%, #ffb800 100%);
    color: #fff;
}

.trends-rank.rank-2 {
    background: linear-gradient(135deg, #c0c0c0 0%, #a0a0a0 100%);
    color: #fff;
}

.trends-rank.rank-3 {
    background: linear-gradient(135deg, #cd7f32 0%, #b87333 100%);
    color: #fff;
}

.trends-rank.rank-other {
    background: #e2e8f0;
    color: #64748b;
}

.trends-term {
    flex: 1;
    font-size: 1rem;
    font-weight: 500;
    color: #1e293b;
}

.trends-arrow {
    color: #94a3b8;
    transition: all 0.3s ease;
}

.trends-item:hover .trends-arrow {
    color: #667eea;
    transform: translateX(3px);
}

/* ========== Loading & Error States ========== */
.trends-loading,
.trends-loading-full {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    color: #64748b;
}

.trends-loading-full {
    min-height: 300px;
}

.trends-error,
.trends-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 40px 20px;
    color: #64748b;
    text-align: center;
}

.trends-error i,
.trends-empty i {
    color: #f59e0b;
}

/* ========== Comparison Section ========== */
.trends-comparison {
    display: flex;
    gap: 20px;
}

.comparison-side {
    flex: 1;
}

.comparison-side h4 {
    font-size: 1rem;
    color: #1e293b;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e2e8f0;
}

.comparison-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.comparison-list li {
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.9rem;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 8px;
}

.comparison-list li:last-child {
    border-bottom: none;
}

.comparison-list li::before {
    content: counter(list-item);
    counter-increment: list-item;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: #e2e8f0;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    flex-shrink: 0;
}

.comparison-list li:first-child::before {
    background: linear-gradient(135deg, #ffd700 0%, #ffb800 100%);
    color: #fff;
}

.comparison-list li:nth-child(2)::before {
    background: linear-gradient(135deg, #c0c0c0 0%, #a0a0a0 100%);
    color: #fff;
}

.comparison-list li:nth-child(3)::before {
    background: linear-gradient(135deg, #cd7f32 0%, #b87333 100%);
    color: #fff;
}

.comparison-divider {
    width: 2px;
    background: linear-gradient(to bottom, transparent, #e2e8f0, transparent);
    margin: 20px 0;
}

.comparison-list a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

.comparison-list a:hover {
    color: #667eea;
}

/* ========== Responsive ========== */
@media (max-width: 991px) {
    .trends-comparison {
        flex-direction: column;
    }

    .comparison-divider {
        width: 100%;
        height: 2px;
        margin: 10px 0;
    }
}

@media (max-width: 767px) {
    .trends-country-tabs {
        grid-template-columns: repeat(2, 1fr);
    }

    .trends-date-btn {
        min-width: calc(50% - 4px);
    }

    .trends-item {
        padding: 12px;
    }

    .trends-rank {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }

    .trends-term {
        font-size: 0.9rem;
    }
}

/* ========== Dashboard Controls (NEW) ========== */
.dashboard-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-group label {
    font-size: 0.9rem;
    color: #64748b;
    font-weight: 500;
    margin: 0;
}

.control-group label i {
    margin-right: 4px;
}

/* Compact Country Tabs */
.trends-country-tabs.compact {
    display: flex;
    gap: 5px;
    grid-template-columns: none;
}

.trends-country-tabs.compact .trends-tab {
    padding: 8px 12px;
    min-width: 50px;
}

/* Compact Date Navigation */
.trends-date-nav.compact {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0;
}

.date-display-compact {
    font-size: 0.9rem;
    color: #1e293b;
    font-weight: 500;
    min-width: 100px;
    text-align: center;
}

/* ========== 3-Column Dashboard Layout (NEW) ========== */
.dashboard-row {
    margin-bottom: 20px;
}

.dashboard-col {
    margin-bottom: 20px;
}

.column-card {
    height: 100%;
    min-height: 600px;
    display: flex;
    flex-direction: column;
}

.column-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e2e8f0;
    font-size: 1.1rem;
    color: #1e293b;
}

.column-title i {
    color: #667eea;
}

/* Vertical Source Tabs */
.trends-source-tabs.vertical {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 15px;
    grid-template-columns: none;
}

.trends-source-tabs.vertical .trends-source-tab {
    width: 100%;
}

/* Inline Tab (for Product Hunt) */
.trends-source-tab.inline-tab {
    margin-left: auto;
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* ========== Hacker News Styles (IDE/Terminal) ========== */
.hn-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    align-items: start;
}

.hn-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.hn-title {
    font-size: 0.95rem;
    font-weight: 500;
    color: #1e293b;
    line-height: 1.4;
}

.hn-meta {
    display: flex;
    gap: 12px;
    font-size: 0.8rem;
    color: #64748b;
}

.hn-domain {
    color: #667eea;
    display: flex;
    align-items: center;
    gap: 4px;
}

.hn-domain i {
    font-size: 0.75rem;
}

.hn-score {
    color: #f59e0b;
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
}

.hn-score i {
    font-size: 0.75rem;
}

/* ========== CoinGecko Styles (Ticker) ========== */
.cg-item {
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    gap: 12px;
    align-items: center;
}

.cg-thumb {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.cg-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cg-name {
    font-size: 0.95rem;
    font-weight: 500;
    color: #1e293b;
}

.cg-meta {
    display: flex;
    gap: 10px;
    font-size: 0.8rem;
}

.cg-price {
    color: #64748b;
    font-weight: 500;
}

.cg-change {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 2px;
}

.cg-change.cg-up {
    color: #10b981;
}

.cg-change.cg-down {
    color: #ef4444;
}

.cg-change i {
    font-size: 0.9rem;
}

/* ========== TMDB Styles (2x2 Poster Grid) ========== */
.tmdb-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.tmdb-card {
    position: relative;
    aspect-ratio: 2/3;
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background: #1e293b;
}

.tmdb-card:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

.tmdb-poster-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
}

.tmdb-poster {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tmdb-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.95), rgba(0, 0, 0, 0.7) 50%, transparent);
    padding: 15px;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tmdb-card:hover .tmdb-overlay {
    opacity: 1;
}

.tmdb-rank {
    font-size: 1.5rem;
    font-weight: 700;
    color: #ffd700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.tmdb-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    line-height: 1.3;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.tmdb-meta {
    display: flex;
    gap: 12px;
    font-size: 0.85rem;
    color: #e2e8f0;
}

.tmdb-type,
.tmdb-rating {
    display: flex;
    align-items: center;
    gap: 4px;
}

.tmdb-rating i {
    color: #ffd700;
}

/* ========== Product Hunt Styles (Horizontal Scroll) ========== */
.ph-scroll {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding: 5px 0;
    margin: -5px 0;
    scrollbar-width: thin;
    scrollbar-color: #667eea #e2e8f0;
}

.ph-scroll::-webkit-scrollbar {
    height: 8px;
}

.ph-scroll::-webkit-scrollbar-track {
    background: #e2e8f0;
    border-radius: 4px;
}

.ph-scroll::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

.ph-scroll::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

.ph-card {
    flex: 0 0 280px;
    display: flex;
    gap: 12px;
    padding: 15px;
    background: #f8fafc;
    border-radius: 12px;
    scroll-snap-align: start;
    transition: all 0.3s ease;
    text-decoration: none;
    color: inherit;
    align-items: start;
}

.ph-card:hover {
    background: #e2e8f0;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.ph-rank {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.ph-rank.rank-1 {
    background: linear-gradient(135deg, #ffd700 0%, #ffb800 100%);
    color: #fff;
}

.ph-rank.rank-2 {
    background: linear-gradient(135deg, #c0c0c0 0%, #a0a0a0 100%);
    color: #fff;
}

.ph-rank.rank-3 {
    background: linear-gradient(135deg, #cd7f32 0%, #b87333 100%);
    color: #fff;
}

.ph-rank.rank-other {
    background: #e2e8f0;
    color: #64748b;
}

.ph-thumb {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.ph-thumb-placeholder {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.ph-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.ph-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.3;
}

.ph-tagline {
    font-size: 0.8rem;
    color: #64748b;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ph-arrow {
    color: #94a3b8;
    transition: all 0.3s ease;
    flex-shrink: 0;
    margin-top: 4px;
}

.ph-card:hover .ph-arrow {
    color: #667eea;
    transform: translateX(3px);
}

/* ========== Responsive - Dashboard Layout ========== */
@media (max-width: 991px) {
    .dashboard-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .control-group {
        justify-content: space-between;
    }

    .column-card {
        min-height: auto;
    }

    .tmdb-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 767px) {
    .dashboard-controls {
        gap: 15px;
    }

    .control-group {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .control-group label {
        width: 100%;
    }

    .trends-country-tabs.compact {
        width: 100%;
    }

    .trends-date-nav.compact {
        width: 100%;
    }

    .tmdb-grid {
        grid-template-columns: 1fr;
    }

    .ph-card {
        flex: 0 0 240px;
    }

    .ph-thumb,
    .ph-thumb-placeholder {
        width: 50px;
        height: 50px;
    }

    .column-card {
        min-height: auto;
    }

    /* Vertical source tabs stay vertical on mobile */
    .trends-source-tabs.vertical {
        gap: 6px;
    }

    .trends-source-tabs.vertical .trends-source-tab {
        padding: 10px 15px;
        font-size: 0.9rem;
    }
}

/* ========== AI Summary Feature (NEW - Project TrendWhat-AI) ========== */

/* AI Summary Header */
.ai-summary-header {
    margin-bottom: 8px;
}

/* AI Badge */
.ai-summary-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    animation: sparkle 2s ease-in-out infinite;
}

.ai-summary-badge i {
    font-size: 0.85rem;
}

@keyframes sparkle {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; transform: scale(1.05); }
}

/* Trends Item Wrapper (for AI summary layout) */
.trends-item-wrapper {
    display: flex;
    flex-direction: column;
    margin-bottom: 2px;
}

.trends-item-wrapper .trends-item {
    margin-bottom: 0;
}

/* AI Summary Container */
.ai-summary-container {
    margin: 0 0 8px 60px; /* Indent to align with text (after rank) */
    padding: 12px 16px;
    background: rgba(102, 126, 234, 0.05);
    border-left: 3px solid #667eea;
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #333;
}

.ai-summary-container.error {
    background: rgba(255, 107, 107, 0.05);
    border-left-color: #ff6b6b;
    color: #d63031;
}

.ai-summary-text {
    margin: 0;
}

.ai-summary-error {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 768px) {
    .ai-summary-badge {
        font-size: 0.7rem;
        padding: 1px 6px;
    }

    .ai-summary-container {
        margin-left: 40px; /* Smaller indent on mobile */
        font-size: 0.85rem;
        padding: 10px 12px;
    }
}
