/* SEO 優化 CSS - 提升頁面性能和用戶體驗 */

/* 核心性能優化 */
* {
    box-sizing: border-box;
}

/* 圖片優化 */
img {
    max-width: 100%;
    height: auto;
    loading: lazy; /* 原生懶加載 */
}

.station-logo {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    transition: transform 0.2s ease;
}

.station-logo:hover {
    transform: scale(1.05);
}

/* 語義化標籤樣式 */
main {
    min-height: 60vh;
}

section {
    margin-bottom: 2rem;
}

article {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

article:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* 可訪問性改善 */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* 焦點指示器 */
.station-logo-container:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
    border-radius: 8px;
}

/* 響應式設計優化 */
.col-5cols {
    position: relative;
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
    margin-bottom: 1rem;
}

@media (max-width: 576px) {
    .col-5cols {
        flex: 0 0 calc(33.333333% - 3px);
        max-width: calc(33.333333% - 3px);
        padding-left: 1.5px;
        padding-right: 1.5px;
        margin-bottom: 10px;
    }
}

@media (min-width: 577px) and (max-width: 768px) {
    .col-5cols {
        flex: 0 0 33.333333%;
        max-width: 33.333333%;
    }
}

@media (min-width: 769px) and (max-width: 992px) {
    .col-5cols {
        flex: 0 0 25%;
        max-width: 25%;
    }
}

@media (min-width: 993px) {
    .col-5cols {
        flex: 0 0 20%;
        max-width: 20%;
    }
}

/* 載入動畫優化 */
.loading-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* 搜索和篩選區域優化 */
.search-filter-section {
    background-color: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
}

/* 電台卡片優化 */
.station-card {
    border: 1px solid #e9ecef;
    border-radius: 8px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.station-card:hover {
    border-color: #007bff;
    box-shadow: 0 2px 8px rgba(0,123,255,0.15);
}

/* 按鈕游標優化 */
.btn, 
button, 
#modalPlayStopBtn, 
#favoriteBtn {
    cursor: pointer !important;
}

.btn:disabled,
button:disabled {
    cursor: not-allowed !important;
}

/* 分頁導航優化 */
.pagination {
    margin-top: 2rem;
}

.page-link {
    color: #007bff;
    border-color: #dee2e6;
}

.page-link:hover {
    color: #0056b3;
    background-color: #e9ecef;
    border-color: #dee2e6;
}

.page-item.active .page-link {
    background-color: #007bff;
    border-color: #007bff;
}

/* 廣告區域優化 */
.ad-container {
    margin: 1rem 0;
    padding: 1rem;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
}

/* 無障礙改善 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 高對比度模式支持 */
@media (prefers-contrast: high) {
    .station-card {
        border-width: 2px;
    }
    
    .station-card:hover {
        border-width: 3px;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    .search-filter-section {
        background-color: #343a40;
        color: #fff;
    }
    
    .station-card {
        background-color: #495057;
        border-color: #6c757d;
        color: #fff;
    }
    
    .ad-container {
        background-color: #343a40;
        border-color: #6c757d;
        color: #fff;
    }
}

/* 性能優化 - 減少重繪 */
.station-logo-container {
    will-change: transform;
}

.station-card {
    will-change: transform, box-shadow;
}

/* 字體優化 */
.station-name {
    font-weight: 500;
    line-height: 1.2;
    color: #212529;
}

/* 錯誤狀態樣式 */
.error-message {
    color: #dc3545;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* 成功狀態樣式 */
.success-message {
    color: #28a745;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* 載入狀態樣式 */
.loading-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}