/* 基本重置和全局樣式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2196F3;
    --secondary-color: #FFC107;
    --success-color: #4CAF50;
    --warning-color: #FF9800;
    --error-color: #F44336;
    --text-primary: #212121;
    --text-secondary: #757575;
    --background-color: #FAFAFA;
    --surface-color: #FFFFFF;
    --border-color: #E0E0E0;
    --footer-background: #1F2937;
    --footer-text: #D1D5DB;
    --shadow-light: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-medium: 0 4px 8px rgba(0,0,0,0.15);
    --shadow-heavy: 0 8px 16px rgba(0,0,0,0.2);
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--background-color);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 標題樣式 */
h1, h2, h3, h4, h5, h6 {
    margin-bottom: 1rem;
    font-weight: 600;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }

/* 按鈕樣式 */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background-color: var(--primary-color);
    color: white;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.btn-secondary {
    background-color: var(--text-secondary);
}

.btn-success {
    background-color: var(--success-color);
}

.btn-warning {
    background-color: var(--warning-color);
}

.btn-error {
    background-color: var(--error-color);
}

/* 頭部樣式 */
header {
    background-color: var(--surface-color);
    box-shadow: var(--shadow-light);
    position: sticky;
    top: 0;
    z-index: 100;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 20px;
}

.logo h1 {
    color: var(--primary-color);
    margin: 0;
    font-size: 1.8rem;
}

nav ul {
    display: flex;
    list-style: none;
    gap: 2rem;
}

nav a {
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

nav a:hover,
nav a.active {
    background-color: var(--primary-color);
    color: white;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#login-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

#login-btn:hover {
    background-color: #1976D2;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-profile img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

/* 主要內容區域 */
main {
    padding: 2rem 0;
    min-height: calc(100vh - 200px);
}

section {
    margin-bottom: 3rem;
    background-color: var(--surface-color);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow-light);
}

/* 位置選擇區域 */
.location-section {
    background: linear-gradient(135deg, var(--primary-color), #1976D2);
    color: white;
}

.location-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.location-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.location-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.location-search {
    display: flex;
    gap: 0.5rem;
    flex: 1;
    min-width: 250px;
}

.location-search input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid transparent;
    border-radius: var(--border-radius);
    background-color: var(--surface-color);
    color: var(--text-primary);
    font-size: 1rem;
}

.location-search input::placeholder { color:var(--text-secondary); opacity:1; }
.location-search input:focus { outline:2px solid rgba(255,255,255,.7); outline-offset:2px; }
:root[data-theme="dark"] .location-search input { background-color:#273449; border-color:#4B5E78; color:#F3F4F6; box-shadow:inset 0 1px 2px rgba(0,0,0,.25); }
:root[data-theme="dark"] .location-search input::placeholder { color:#AEBACB; }
:root[data-theme="dark"] .location-section {
    background:#1F2937;
    border:1px solid #334A67;
    box-shadow:0 8px 24px rgba(0,0,0,.24);
    color:#EAF2FF;
}
:root[data-theme="dark"] .location-btn {
    background-color:#304968;
    border:1px solid #496889;
    color:#EAF2FF;
}
:root[data-theme="dark"] .location-btn:hover { background-color:#3A587B; border-color:#60A5FA; }
:root[data-theme="dark"] .location-name { color:#F3F7FF; }
:root[data-theme="dark"] .location-coords { background-color:#172235; border:1px solid #3A5270; color:#C5D5E8; }

.location-search button {
    background-color: var(--secondary-color);
    color: var(--text-primary);
    border: none;
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.current-location {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
}

.location-name {
    font-size: 1.2rem;
    font-weight: 600;
}

.location-coords {
    font-size: 0.85rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.85);
    background-color: rgba(0, 0, 0, 0.15);
    padding: 0.2rem 0.6rem;
    border-radius: 8px;
}

/* 當前天氣區域 */
.current-weather {
    text-align: center;
}

.weather-main {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2rem;
}

.weather-icon img {
    width: 120px;
    height: 120px;
}

.weather-info {
    text-align: left;
}

.temperature {
    font-size: 4rem;
    font-weight: 300;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.weather-description {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.feels-like,
.temp-range {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.weather-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    padding: 1rem;
    background-color: var(--background-color);
    border-radius: var(--border-radius);
}

.detail-item .label {
    color: var(--text-secondary);
}

.sun-times {
    display: flex;
    justify-content: center;
    gap: 3rem;
}

.sun-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.sun-item .label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* 穿著建議區域 */
.clothing-overview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: -0.25rem 0 1.25rem;
    padding: 0.85rem 1rem;
    background: rgba(33, 150, 243, 0.08);
    border-left: 4px solid var(--primary-color);
    border-radius: 8px;
}
:root[data-theme="dark"] .location-search button { color:#1F2937; }

:root[data-theme="dark"] { --primary-color:#60A5FA; --secondary-color:#FBBF24; --text-primary:#F3F4F6; --text-secondary:#B6C0CE; --background-color:#111827; --surface-color:#1F2937; --border-color:#374151; --shadow-light:0 2px 5px rgba(0,0,0,.3); --shadow-medium:0 6px 14px rgba(0,0,0,.38); --shadow-heavy:0 12px 24px rgba(0,0,0,.45); color-scheme:dark; }
:root[data-theme="ocean"] { --primary-color:#007C91; --secondary-color:#F2B84B; --text-primary:#15343B; --text-secondary:#58747A; --background-color:#EAF6F7; --surface-color:#FFFFFF; --border-color:#C5E1E4; }
:root[data-theme="forest"] { --primary-color:#39734D; --secondary-color:#D29B45; --text-primary:#23362A; --text-secondary:#657568; --background-color:#EFF5ED; --surface-color:#FFFFFF; --border-color:#D1DFCE; }
:root[data-theme="sunset"] { --primary-color:#D9573F; --secondary-color:#F0A543; --text-primary:#452E31; --text-secondary:#806467; --background-color:#FFF3EC; --surface-color:#FFFFFF; --border-color:#F1D5C9; }
:root[data-theme="rose"] { --primary-color:#B64C70; --secondary-color:#5E7FA3; --text-primary:#3D3038; --text-secondary:#78646F; --background-color:#FAF0F4; --surface-color:#FFFFFF; --border-color:#E9D2DC; }

.clothing-overview p { margin: 0; color: var(--text-secondary); }

#clothing-comfort-badge {
    flex: 0 0 auto;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    color: white;
    background: var(--primary-color);
    font-size: 0.8rem;
    font-weight: 700;
}

.clothing-tip {
    margin: 1.25rem 0 0;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.suggestions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.suggestion-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    background-color: var(--background-color);
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.suggestion-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.suggestion-icon img {
    width: 60px;
    height: 60px;
}

.suggestion-text h3 {
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.suggestion-text p {
    color: var(--text-secondary);
    margin: 0;
}

@media (max-width: 560px) {
    .clothing-overview { align-items: flex-start; flex-direction: column; }
}

/* Section Header for titles with buttons */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-header h2 {
    margin-bottom: 0;
}

.time-format-btn {
    background-color: var(--background-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.25rem 0.75rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: var(--transition);
}

.time-format-btn:hover {
    background-color: var(--border-color);
}

/* 每小時預報區域 */
.hourly-scroll {
    overflow-x: auto;
    padding-bottom: 1rem;
}

.hourly-container {
    display: flex;
    gap: 1rem;
    min-width: max-content;
}

.hourly-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    background-color: var(--background-color);
    border-radius: var(--border-radius);
    min-width: 100px;
    text-align: center;
}

.hourly-time {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.hourly-icon img {
    width: 40px;
    height: 40px;
    margin-bottom: 0.5rem;
}

.hourly-temp {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.hourly-rain {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* 溫度趨勢圖 */
.chart-container {
    position: relative;
    height: 300px;
    background-color: var(--background-color);
    border-radius: var(--border-radius);
    padding: 1rem;
}

#temperature-chart-canvas {
    width: 100%;
    height: 100%;
}

/* 7天預報區域 */
.weekly-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.weekly-item {
    display: grid;
    grid-template-columns: 100px 1fr auto; /* Date | Icon + Desc | Temps */
    align-items: center;
    padding: 1rem;
    background-color: var(--background-color);
    border-radius: var(--border-radius);
    transition: var(--transition);
    gap: 1rem;
}

.weekly-item:hover {
    transform: translateX(5px);
    box-shadow: var(--shadow-light);
}

.weekly-date {
    font-weight: 500;
}

.weekly-weather-icon-and-desc {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.weekly-icon-medium {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
}

.weekly-desc {
    color: var(--text-primary);
    font-weight: 500;
    margin: 0;
}

.weekly-temperatures {
    display: flex;
    flex-direction: column;
    align-items: flex-end; /* Align children to the right */
}

.weekly-temp-max {
    font-weight: 600;
    color: var(--error-color); /* Changed to red */
}

.weekly-temp-min {
    color: var(--primary-color); /* Changed to blue */
}

/* Responsive adjustments for weekly-item */
@media (max-width: 768px) {
    .weekly-item {
        grid-template-columns: 1fr; /* Stack items vertically on smaller screens */
        text-align: center;
        justify-items: center; /* Center items horizontally */
    }

    .weekly-date {
        width: auto; /* Remove fixed width */
    }

    .weekly-weather-icon-and-desc {
        justify-content: center; /* Center icon and description */
    }

    .weekly-temp-max,
    .weekly-temp-min {
        text-align: center; /* Center temperature text */
    }
}

/* 快速操作區域 */
.actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.action-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    background-color: var(--background-color);
    border-radius: var(--border-radius);
    text-decoration: none;
    color: var(--text-primary);
    transition: var(--transition);
}

.action-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
    background-color: var(--primary-color);
    color: white;
}

.action-icon {
    font-size: 2rem;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--primary-color);
    color: white;
    border-radius: 50%;
}

.action-item:hover .action-icon {
    background-color: white;
    color: var(--primary-color);
}

.action-text h3 {
    margin-bottom: 0.5rem;
}

.action-text p {
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.8;
}

/* 頁腳樣式 */
footer {
    background-color: var(--footer-background);
    color: var(--footer-text);
    padding: 3rem 0 1rem;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-logo h2 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.footer-links ul {
    list-style: none;
}

.footer-links a {
    color: var(--footer-text);
    text-decoration: none;
    transition: var(--transition);
}

.footer-links a:hover {
    color: var(--primary-color);
}

.social-links {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.social-link {
    color: var(--footer-text);
    text-decoration: none;
    transition: var(--transition);
}

.social-link:hover {
    color: var(--primary-color);
}

.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid #444;
    color: var(--footer-text);
}

footer p { color:var(--footer-text); }

/* 載入中遮罩 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

/* 響應式設計 */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    header .container {
        flex-direction: column;
        gap: 1rem;
    }
    
    nav ul {
        flex-wrap: wrap;
        justify-content: center;
        gap: 1rem;
    }
    
    .weather-main {
        flex-direction: column;
        text-align: center;
    }
    
    .weather-info {
        text-align: center;
    }
    
    .temperature {
        font-size: 3rem;
    }
    
    .location-controls {
        flex-direction: column;
    }
    
    .location-search {
        min-width: auto;
    }
    
    .suggestions-grid {
        grid-template-columns: 1fr;
    }
    
    .actions-grid {
        grid-template-columns: 1fr;
    }
    
    .sun-times {
        gap: 2rem;
    }
    
    .weekly-item {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    
    .weekly-weather {
        justify-content: center;
    }
    
    .weekly-temps {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .logo h1 {
        font-size: 1.5rem;
    }
    
    nav ul {
        gap: 0.5rem;
    }
    
    nav a {
        padding: 0.25rem 0.5rem;
        font-size: 0.9rem;
    }
    
    section {
        padding: 1rem;
        margin-bottom: 2rem;
    }
    
    .temperature {
        font-size: 2.5rem;
    }
    
    .weather-details {
        grid-template-columns: 1fr;
    }
    
    .hourly-item {
        min-width: 80px;
        padding: 0.75rem;
    }
    
    .action-item {
        padding: 1rem;
    }
    
    .action-icon {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
}

/* 深色模式支援 */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --text-primary: #FFFFFF;
        --text-secondary: #CCCCCC;
        --background-color: #121212;
        --surface-color: #1E1E1E;
        --border-color: #333333;
    }
    
    body {
        background-color: var(--background-color);
        color: var(--text-primary);
    }
}

/* 動畫效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

/* 可訪問性改進 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 高對比度模式 */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #0066CC;
        --border-color: #000000;
        --shadow-light: 0 2px 4px rgba(0,0,0,0.3);
        --shadow-medium: 0 4px 8px rgba(0,0,0,0.4);
        --shadow-heavy: 0 8px 16px rgba(0,0,0,0.5);
    }
}

