/* ==================== 基础样式 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-color: #1a1a1a;
    --text-color: #ffffff;
    --card-bg: #2a2a2a;
    --card-text: #ffffff;
    --accent-color: #4a9eff;
    --flip-duration: 0.6s;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    transition: background 0.5s ease;
    min-height: 100vh;
}

/* ==================== 顶部信息栏 ==================== */
.info-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    z-index: 100;
    opacity: 0.8;
    transition: opacity 0.3s;
}

.info-bar:hover {
    opacity: 1;
}

.date-info {
    display: flex;
    gap: 15px;
    font-size: 14px;
    font-weight: 300;
    letter-spacing: 1px;
}

.controls {
    display: flex;
    gap: 10px;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.3s;
    color: inherit;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.icon-btn svg {
    fill: currentColor;
}

/* ==================== 主时钟容器 ==================== */
.clock-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    gap: 40px;
}

/* ==================== 翻页时钟 ==================== */
.flip-clock {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0;
}

.flip-unit {
    position: relative;
    width: 100px;
    height: 140px;
    perspective: 600px;
    border-radius: 10px;
    overflow: hidden;
}

.flip-unit-small {
    width: 100px;
    height: 140px;
}

/* 添加卡片背景容器 */
.flip-unit::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--card-bg);
    border-radius: 10px;
    z-index: 0;
}

.flip-card {
    position: absolute;
    left: 0;
    width: 100%;
    height: 50%;
    overflow: hidden;
    transform-style: preserve-3d;
    backface-visibility: hidden;
    z-index: 1;
}

.flip-card.top {
    top: 0;
    transform-origin: bottom center;
    z-index: 1;
}

.flip-card.bottom {
    bottom: 0;
    transform-origin: top center;
    z-index: 0;
}

.flip-card .face {
    position: absolute;
    left: 0;
    width: 100%;
    height: 140px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 80px;
    font-weight: 700;
    background: transparent;
    color: var(--card-text);
    line-height: 140px;
}

/* Top card shows top half */
.flip-card.top .face.top {
    top: 0;
}

.flip-card.top .face.bottom {
    top: -70px;
}

/* Bottom card shows bottom half */
.flip-card.bottom .face.top {
    top: -140px;
}

.flip-card.bottom .face.bottom {
    top: -70px;
}

.flip-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.flip-overlay-top,
.flip-overlay-bottom {
    position: absolute;
    left: 0;
    width: 100%;
    height: 50%;
    overflow: hidden;
    transform-style: preserve-3d;
    backface-visibility: hidden;
}

.flip-overlay-top {
    top: 0;
    transform-origin: bottom center;
}

.flip-overlay-bottom {
    bottom: 0;
    transform-origin: top center;
}

.flip-overlay-top .face,
.flip-overlay-bottom .face {
    position: absolute;
    left: 0;
    width: 100%;
    height: 140px;
    display: flex !important;
    justify-content: center;
    align-items: center;
    font-size: 80px;
    font-weight: 700;
    background: transparent;
    color: var(--card-text);
    line-height: 140px;
}

.flip-overlay-top .face {
    top: 0;
}

.flip-overlay-bottom .face {
    top: -140px;
}

/* 翻页动画 */
.flip-unit.flipping .flip-overlay-top {
    animation: flip-top 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.flip-unit.flipping .flip-overlay-bottom {
    animation: flip-bottom 0.25s cubic-bezier(0.4, 0, 0.2, 1) 0.25s forwards;
}

@keyframes flip-top {
    0% {
        transform: rotateX(0deg);
    }
    100% {
        transform: rotateX(-90deg);
    }
}

@keyframes flip-bottom {
    0% {
        transform: rotateX(90deg);
    }
    100% {
        transform: rotateX(0deg);
    }
}

.separator {
    font-size: 60px;
    font-weight: 200;
    margin: 0 8px;
    opacity: 0.5;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 0.8; }
}

.seconds-container {
    display: flex;
    align-items: center;
    gap: 12px;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==================== 模式控制区 ==================== */
.mode-controls {
    text-align: center;
}

.timer-display {
    font-size: 24px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    justify-content: center;
}

#timerValue {
    font-size: 48px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.timer-label {
    font-size: 16px;
    opacity: 0.7;
    padding: 4px 12px;
    background: rgba(255,255,255,0.1);
    border-radius: 20px;
}

.timer-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.timer-buttons button {
    padding: 10px 20px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.05);
    color: inherit;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.timer-buttons button:hover {
    background: rgba(255,255,255,0.15);
}

.timer-buttons button.primary {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
}

.timer-buttons button.primary:hover {
    filter: brightness(1.1);
}

/* ==================== 设置面板 ==================== */
.settings-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 380px;
    height: 100%;
    background: rgba(20, 20, 20, 0.95);
    backdrop-filter: blur(20px);
    z-index: 1000;
    transition: right 0.3s ease;
    overflow-y: auto;
}

.settings-panel.open {
    right: 0;
}

.settings-content {
    padding: 20px;
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.settings-header h2 {
    font-size: 24px;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
    transition: opacity 0.3s;
}

.close-btn:hover {
    opacity: 1;
}

.settings-section {
    margin-bottom: 30px;
}

.settings-section h3 {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 15px;
    opacity: 0.6;
}

.option-group {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.option-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px;
    border: 2px solid rgba(255,255,255,0.1);
    background: transparent;
    color: inherit;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 14px;
}

.option-btn:hover {
    border-color: rgba(255,255,255,0.3);
}

.option-btn.active {
    border-color: var(--accent-color);
    background: rgba(74, 158, 255, 0.1);
}

.option-btn .icon {
    font-size: 20px;
}

.option-btn .preview {
    width: 30px;
    height: 30px;
    border-radius: 6px;
}

.theme-preview-minimal { background: linear-gradient(135deg, #0d0d0d, #1a1a1a); }
.theme-preview-retro { background: linear-gradient(135deg, #1a1815, #2d2924); }
.theme-preview-nightlight { background: linear-gradient(135deg, #0f1c2e, #1e3a5f); }
.theme-preview-cute { background: linear-gradient(135deg, #fff5f8, #ffe4f0); }

.toggle-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 10px 0;
}

.toggle input[type="checkbox"] {
    appearance: none;
    width: 44px;
    height: 24px;
    background: rgba(255,255,255,0.2);
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s;
}

.toggle input[type="checkbox"]::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: transform 0.3s;
}

.toggle input[type="checkbox"]:checked {
    background: var(--accent-color);
}

.toggle input[type="checkbox"]:checked::before {
    transform: translateX(20px);
}

select {
    width: 100%;
    padding: 12px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    background: rgba(255,255,255,0.05);
    color: inherit;
    font-size: 14px;
    cursor: pointer;
}

select option {
    background: #1a1a1a;
}

/* ==================== 弹窗 ==================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 1100;
    justify-content: center;
    align-items: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 16px;
    min-width: 300px;
}

.modal-content h3 {
    margin-bottom: 20px;
}

.countdown-inputs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.countdown-inputs > div {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.countdown-inputs label {
    font-size: 12px;
    opacity: 0.7;
}

.countdown-inputs input {
    padding: 12px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    background: rgba(0,0,0,0.2);
    color: inherit;
    font-size: 18px;
    text-align: center;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-buttons button {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.3s;
}

.modal-buttons button:first-child {
    background: rgba(255,255,255,0.1);
    color: inherit;
}

.modal-buttons button:last-child {
    background: var(--accent-color);
    color: white;
}

/* ==================== 主题样式 ==================== */

/* 极简黑白 */
.theme-minimal {
    --bg-color: #0d0d0d;
    --text-color: #ffffff;
    --card-bg: #1a1a1a;
    --card-text: #ffffff;
    --accent-color: #ffffff;
}

.theme-minimal .flip-unit::before {
    background: linear-gradient(180deg, #1a1a1a 0%, #0f0f0f 100%);
}

/* 复古机场 */
.theme-retro {
    --bg-color: #1a1815;
    --text-color: #d4c5b0;
    --card-bg: linear-gradient(180deg, #2d2924, #1f1d19);
    --card-text: #f0e6d6;
    --accent-color: #c9a86c;
}

.theme-retro {
    background: #1a1815;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(255,255,255,0.02) 1px, transparent 1px),
        radial-gradient(circle at 70% 70%, rgba(255,255,255,0.015) 1px, transparent 1px);
    background-size: 24px 24px, 32px 32px;
}

.theme-retro .flip-card .face {
    color: #f0e6d6;
    text-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

.theme-retro .flip-unit::before {
    background: linear-gradient(180deg, #2d2924, #1f1d19);
}

/* 柔和夜灯 */
.theme-nightlight {
    --bg-color: #0f1c2e;
    --text-color: #e8f4fc;
    --card-bg: linear-gradient(180deg, #1e3a5f, #152a45);
    --card-text: #ffffff;
    --accent-color: #7ec8e3;
}

.theme-nightlight {
    background: linear-gradient(135deg, #0f1c2e 0%, #1a2d47 50%, #0f1c2e 100%);
}

.theme-nightlight .flip-card .face {
    color: #ffffff;
}

.theme-nightlight .flip-unit::before {
    background: linear-gradient(180deg, rgba(45, 74, 111, 0.8), rgba(30, 55, 85, 0.7));
}

.theme-nightlight .separator {
    text-shadow: 0 0 20px rgba(126, 200, 227, 0.6);
    color: #7ec8e3;
}

/* 可爱主题 */
.theme-cute {
    --bg-color: #fff5f8;
    --text-color: #6b4c5a;
    --card-bg: linear-gradient(180deg, #ffeef4, #ffe4ef);
    --card-text: #ff6b9d;
    --accent-color: #ff6b9d;
}

.theme-cute {
    background: linear-gradient(135deg, #fff5f8 0%, #ffeef2 50%, #ffd9e8 100%);
}

.theme-cute .flip-card .face {
    color: #ff6b9d;
    font-family: 'Segoe UI', 'Comic Sans MS', cursive, sans-serif;
    text-shadow: 0 1px 2px rgba(255, 107, 157, 0.2);
}

.theme-cute .flip-unit::before {
    background: linear-gradient(180deg, #ffeef4, #ffe4f0);
}

.theme-cute .separator {
    color: #ff8fb5;
    text-shadow: 0 0 10px rgba(255, 107, 157, 0.3);
}

/* ==================== 模式样式 ==================== */

/* 纯展示型 - 沉浸式 */
.mode-display .info-bar {
    opacity: 0;
    transition: opacity 0.5s;
}

.mode-display:hover .info-bar {
    opacity: 0.8;
}

.mode-display .flip-clock {
    transform: scale(1.2);
}

/* 专注工具型 */
.mode-focus {
    --bg-color: #0f1419;
}

.mode-focus .mode-controls {
    display: block;
}

.mode-focus .flip-clock {
    margin-bottom: 20px;
}

/* 氛围装饰型 */
.mode-ambient .flip-unit {
    animation: breathe 4s ease-in-out infinite;
}

.mode-ambient .flip-unit:nth-child(2) { animation-delay: 0.5s; }
.mode-ambient .flip-unit:nth-child(4) { animation-delay: 1s; }
.mode-ambient .flip-unit:nth-child(5) { animation-delay: 1.5s; }

@keyframes breathe {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.2); }
}

.mode-ambient.theme-nightlight .flip-unit {
    animation: glow-pulse 3s ease-in-out infinite;
}

@keyframes glow-pulse {
    0%, 100% {
        filter: drop-shadow(0 0 20px rgba(126, 200, 227, 0.3));
    }
    50% {
        filter: drop-shadow(0 0 40px rgba(126, 200, 227, 0.6));
    }
}

/* ==================== 响应式 ==================== */
@media (max-width: 768px) {
    .flip-unit {
        width: 60px;
        height: 84px;
    }

    .flip-card .face {
        font-size: 48px;
        height: 84px;
        line-height: 84px;
    }

    .flip-overlay-top .face,
    .flip-overlay-bottom .face {
        font-size: 48px;
        height: 84px;
        line-height: 84px;
    }

    .separator {
        font-size: 36px;
    }

    .settings-panel {
        width: 100%;
        right: -100%;
    }

    .flip-clock {
        transform: scale(0.8);
    }
}

@media (max-width: 480px) {
    .flip-unit {
        width: 45px;
        height: 63px;
    }

    .flip-card .face {
        font-size: 36px;
        height: 63px;
        line-height: 63px;
    }

    .flip-overlay-top .face,
    .flip-overlay-bottom .face {
        font-size: 36px;
        height: 63px;
        line-height: 63px;
    }

    .separator {
        font-size: 28px;
    }
}

/* ==================== 全屏模式 ==================== */
:fullscreen .info-bar {
    opacity: 0;
}

:fullscreen:hover .info-bar {
    opacity: 1;
}

:fullscreen .flip-clock {
    transform: scale(1.5);
}

/* ==================== PWA 安装提示 ==================== */
.pwa-install-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--card-bg);
    padding: 15px 25px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    z-index: 999;
    transition: transform 0.3s;
    display: flex;
    align-items: center;
    gap: 15px;
}

.pwa-install-banner.show {
    transform: translateX(-50%) translateY(0);
}

.pwa-install-banner button {
    padding: 8px 16px;
    background: var(--accent-color);
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
}
