/* ============================================
   婆婆天气 - 为老人设计的天气预报
   自适应屏幕设计 - 优雅布局
   ============================================ */

/* CSS变量 */
:root {
    --bg-color: #e0e8f0;
    --card-good: #e3f2fd;  /* 好天气淡蓝色 */
    --card-bad: #f5f5f5;   /* 坏天气浅灰色 */
    --card-rain: #f5f5f5;  /* 雨天浅灰色 */
    --card-extreme: #ffebee;  /* 极端天气浅红色 */
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-date: #666666;
    --temp-high: #ff6b6b;
    --temp-low: #4ecdc4;
    --alert-bg: #fff3e0;
    --alert-border: #ff9800;
    --alert-text: #e65100;
    --btn-primary: #1976D2;
    --btn-hover: #1565C0;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-strong: rgba(0, 0, 0, 0.15);
}

/* 重置样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* 禁止滚动 */
body {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    touch-action: none;
}

/* 容器 */
.container {
    width: 100vw;
    height: 100vh;
    max-width: 1280px;
    max-height: 800px;
    margin: 0 auto;
    padding: 12px 18px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* 视图切换 */
.view {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    transition: opacity 0.3s ease;
}

.view.hidden {
    display: none;
    opacity: 0;
}

/* ============================================
   头部样式
   ============================================ */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 8px 8px;
    flex-shrink: 0;
}

.date-display {
    display: flex;
    gap: 12px;
    font-size: 30px;
    font-weight: 500;
    color: #666;
}

#current-date {
    letter-spacing: 1px;
}

#current-weekday {
    color: #666;
}

.header-buttons {
    display: flex;
    gap: 20px;
    align-items: center;
}

/* 播报按钮 - 加大 */
.play-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 35px;
    font-size: 32px;
    font-weight: bold;
    color: #f5f5f5;
    background: #1976D2;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 240px;
}

.play-btn svg {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
}

.play-btn .icon-pause {
    display: none;
}

.play-btn.playing .icon-play {
    display: none;
}

.play-btn.playing .icon-pause {
    display: block;
}

.play-btn .audio-text {
    font-size: 32px;
    font-weight: bold;
}

.play-btn:hover {
    transform: scale(1.05);
    background: #1565C0;
    box-shadow: 0 6px 16px rgba(25, 118, 210, 0.4);
}

.play-btn:active {
    transform: scale(0.95);
}

/* 播放中状态 - 淡蓝色 */
.play-btn.playing {
    background: #42A5F5;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 4px 12px rgba(66, 165, 245, 0.3); }
    50% { box-shadow: 0 4px 20px rgba(66, 165, 245, 0.5); }
}

/* 设置按钮 */
.settings-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 22px;
    background: #999999;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    font-size: 26px;
    font-weight: bold;
    color: white;
}

.settings-btn svg {
    width: 24px;
    height: 24px;
    fill: white;
}

.settings-btn:hover {
    background: #757575;
}

/* 返回按钮 - 与播放按钮大小一致 */
.back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 25px;
    font-size: 28px;
    font-weight: bold;
    color: white;
    background: #4CAF50;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    min-width: 160px;
}

.back-btn svg {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    fill: white;
    stroke: white;
    stroke-width: 1px;
}

.back-btn:hover {
    background: #43a047;
    transform: translateX(-4px);
}

/* ============================================
   预警信息样式
   ============================================ */
.alert-container {
    background: #fff3e0;
    border: 3px solid #ff9800;
    border-radius: 12px;
    padding: 8px 15px;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.alert-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
}

.alert-badge svg {
    width: 24px;
    height: 24px;
    fill: #e65100;
    flex-shrink: 0;
}

.alert-badge span {
    font-size: 22px;
    font-weight: bold;
    color: #e65100;
}

.alert-content {
    font-size: 18px;
    font-weight: 500;
    color: #333;
    line-height: 1.5;
}

/* ============================================
   天气卡片区域 - 紧凑优雅布局
   ============================================ */
.weather-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    flex: 1;
    min-height: 0;
}

.weather-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 15px 18px 18px;
    background: var(--card-good);
    border-radius: 20px;
    cursor: pointer;
    transition: transform 0.2s;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    position: relative;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.weather-card * {
    pointer-events: none;
}

.weather-card:hover {
    transform: scale(1.03);
}

.weather-card:active {
    transform: scale(0.98);
}

/* 不同天气类型的卡片颜色 */
.weather-card.bad-weather {
    background: var(--card-bad);
}

.weather-card.rainy {
    background: var(--card-rain);
}

.weather-card.extreme {
    background: var(--card-extreme);
    border: 3px solid #ef9a9a;
}

.weather-card.extreme::before {
    content: '';
}

.extreme-warning {
    position: absolute;
    top: 8px;
    right: 8px;
    background-color: #ff6b6b;
    color: white;
    padding: 4px 8px;
    border-radius: 5px;
    font-size: 16px;
    font-weight: bold;
    z-index: 10;
}

/* 卡片内容 - 优雅布局 */
.card-weekday {
    font-size: 26px;
    font-weight: bold;
    color: #555;
    margin-bottom: 4px;
}

.card-date {
    font-size: 18px;
    font-weight: normal;
    color: #888;
    margin-bottom: 12px;
}

.weather-icon {
    width: 100px;
    height: 100px;
    margin: 0 auto 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.weather-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
}

.weather-status {
    font-size: 34px;
    font-weight: bold;
    color: #666;
    text-align: center;
    margin-bottom: 12px;
}

.temperature-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.temp-high {
    font-size: 38px;
    font-weight: bold;
    color: #ff6b6b;
}

.temp-low {
    font-size: 38px;
    font-weight: bold;
    color: #3bb8b0;
}

.wind-info {
    font-size: 32px;
    font-weight: 500;
    color: #999;
    text-align: center;
    margin-top: 8px;
}

/* ============================================
   小时级别卡片（详情页）- 优雅布局
   ============================================ */
.hourly-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    flex: 1;
    min-height: 0;
    margin-top: 5px;
}

.hourly-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 15px 18px 18px;
    background: var(--card-good);
    border-radius: 20px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.hourly-card.bad-weather {
    background: var(--card-bad);
}

.hourly-card.rainy {
    background: var(--card-rain);
}

.hourly-card.extreme {
    background: var(--card-extreme);
    border: 3px solid #ef9a9a;
}

.time-period {
    font-size: 26px;
    font-weight: bold;
    color: #555;
    margin-bottom: 4px;
}

.time-label {
    font-size: 18px;
    font-weight: normal;
    font-style: italic;
    color: #888;
    margin-bottom: 12px;
}

.hourly-card .weather-icon {
    width: 100px;
    height: 100px;
    margin: 0 auto 12px;
}

.hourly-card .weather-status {
    font-size: 34px;
    font-weight: bold;
    color: #333;
    margin-bottom: 12px;
}

.hourly-card .temperature {
    font-size: 38px;
    font-weight: bold;
    color: #444;
    margin-bottom: 12px;
}

.rain-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 30px;
    font-weight: bold;
    margin-bottom: 10px;
}

.rain-status.will-rain {
    color: #1565C0;
}

.rain-status.no-rain {
    color: #43a047;
}

.rain-status svg {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
}

.hourly-card .wind-info {
    font-size: 32px;
    font-weight: 500;
    color: #999;
    margin-top: 8px;
}

/* 详情页标题 - 移到右边 */
.detail-title {
    display: flex;
    gap: 15px;
    font-size: 32px;
    font-weight: bold;
    color: #333;
}

/* 占位元素，保持header布局平衡 - 左边不需要 */
.header-spacer {
    width: 0;
}

/* ============================================
   设置页面
   ============================================ */
.settings-title {
    font-size: 36px;
    font-weight: bold;
    color: #333;
}

.settings-content {
    display: flex;
    flex-direction: column;
    gap: 25px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    padding: 0 20px;
}

.settings-card {
    background: white;
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 10px;
}

.setting-info h2 {
    font-size: 28px;
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
}

.setting-info p {
    font-size: 20px;
    color: #666;
}

.version {
    font-size: 24px;
    font-weight: 500;
    color: #666;
}

/* 开关按钮 */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 80px;
    height: 44px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.4s;
    border-radius: 44px;
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 36px;
    width: 36px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: #2196F3;
}

input:focus + .toggle-slider {
    box-shadow: 0 0 1px #2196F3;
}

input:checked + .toggle-slider::before {
    transform: translateX(36px);
}

/* ============================================
   加载动画
   ============================================ */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    grid-column: 1 / -1;
    padding: 20px;
    text-align: center;
    color: #666;
    font-size: 18px;
    font-weight: 500;
    animation: loadingPulse 1.5s infinite;
}

@keyframes loadingPulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #e0e0e0;
    border-top-color: #1976D2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading p {
    margin-top: 15px;
    font-size: 20px;
    color: #666;
}

/* 错误提示 */
.error-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #ff4d4f;
    color: white;
    padding: 15px 25px;
    border-radius: 5px;
    font-size: 16px;
    font-weight: bold;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(255, 77, 79, 0.3);
}

.error-message svg {
    width: 60px;
    height: 60px;
    fill: white;
    margin-bottom: 15px;
}

.error-message h3 {
    font-size: 24px;
    color: white;
    margin-bottom: 10px;
}

.error-message p {
    font-size: 18px;
    color: white;
}

.retry-btn {
    margin-top: 20px;
    padding: 12px 30px;
    font-size: 20px;
    font-weight: bold;
    color: #ff4d4f;
    background: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s;
}

.retry-btn:hover {
    background: #f5f5f5;
}
