/* ==========================================
   老年收音机 - 样式表
   设计原则：大字体、高对比度、拟物旋钮、触控友好
   ========================================== */

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-panel: #0f3460;
    --text-primary: #e8e8e8;
    --text-secondary: #a0a0b0;
    --accent-gold: #c9a84c;
    --accent-red: #e94560;
    --accent-green: #4caf50;
    --accent-blue: #4a90d9;
    --knob-bg: #2c2c3e;
    --knob-border: #4a4a5e;
    --btn-radius: 16px;
    --font-xl: 2rem;
    --font-lg: 1.4rem;
    --font-md: 1.1rem;
    --font-sm: 0.9rem;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

/* --- App Container --- */
.app-container {
    width: 100%;
    height: 100%;
    max-width: 480px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
    position: relative;
}

/* --- Status Bar --- */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: rgba(0,0,0,0.3);
    font-size: var(--font-sm);
    color: var(--text-secondary);
}

.device-name {
    font-weight: bold;
    color: var(--accent-gold);
    font-size: var(--font-md);
}

/* --- Main Panel --- */
.main-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px;
    gap: 16px;
    overflow-y: auto;
}

/* --- Display Area --- */
.display-area {
    background: #0a0a1a;
    border-radius: 16px;
    padding: 20px;
    border: 2px solid #2a2a3e;
    text-align: center;
}

.channel-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
}

.channel-icon {
    font-size: 2.5rem;
}

.channel-name {
    font-size: var(--font-xl);
    font-weight: bold;
    color: var(--accent-gold);
}

.year-display {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 4px;
    margin-bottom: 8px;
}

.year-label {
    font-size: var(--font-md);
    color: var(--text-secondary);
}

.year-value {
    font-size: 3rem;
    font-weight: bold;
    color: #fff;
    font-family: 'Courier New', monospace;
    text-shadow: 0 0 20px rgba(201, 168, 76, 0.5);
}

.year-unit {
    font-size: var(--font-lg);
    color: var(--text-secondary);
}

.status-indicator {
    font-size: var(--font-sm);
    color: var(--accent-green);
}

.status-indicator.playing {
    color: var(--accent-green);
    animation: blink 1s infinite;
}

.status-indicator.loading {
    color: var(--accent-gold);
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* --- Frequency Bar --- */
.frequency-bar {
    position: relative;
    height: 40px;
    background: #0a0a1a;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #2a2a3e;
}

.freq-fill {
    height: 100%;
    background: linear-gradient(90deg, #e94560, #c9a84c, #4caf50, #4a90d9, #c9a84c, #e94560);
    width: 50%;
    transition: width 0.3s ease;
    opacity: 0.4;
}

.freq-marker {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.7rem;
    color: var(--text-secondary);
    pointer-events: none;
}

/* --- Controls Area --- */
.controls-area {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.knobs-row {
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.knob-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.knob-label {
    font-size: var(--font-md);
    color: var(--text-secondary);
    font-weight: bold;
}

/* --- Knob (旋钮) --- */
.knob {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 40%, #4a4a5e, #2c2c3e);
    border: 4px solid var(--knob-border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow:
        0 6px 20px rgba(0,0,0,0.5),
        inset 0 2px 4px rgba(255,255,255,0.1);
    transition: transform 0.1s ease;
    touch-action: none;
    position: relative;
}

.knob:active {
    transform: scale(0.95);
}

.knob-inner {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 40%, #5a5a6e, #3a3a4e);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.knob-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-gold);
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
}

.knob-value {
    font-size: var(--font-md);
    color: #fff;
    font-weight: bold;
    text-align: center;
    min-width: 60px;
}

/* --- PTT Button (对讲按键) --- */
.ptt-button {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 40%, #e94560, #b8304f);
    border: 4px solid #ff6b81;
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow:
        0 6px 20px rgba(233, 69, 96, 0.4),
        inset 0 2px 4px rgba(255,255,255,0.2);
    transition: all 0.15s ease;
    touch-action: none;
    gap: 4px;
}

.ptt-button:active,
.ptt-button.pressed {
    transform: scale(0.9);
    background: radial-gradient(circle at 40% 40%, #ff6b81, #e94560);
    box-shadow:
        0 2px 8px rgba(233, 69, 96, 0.8),
        inset 0 4px 8px rgba(0,0,0,0.3);
}

.ptt-icon {
    font-size: 1.8rem;
}

.ptt-text {
    font-size: 0.8rem;
    font-weight: bold;
}

/* --- Action Bar --- */
.action-bar {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.action-btn {
    flex: 1;
    max-width: 160px;
    padding: 16px 24px;
    border-radius: var(--btn-radius);
    border: none;
    font-size: var(--font-lg);
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.play-btn {
    background: linear-gradient(135deg, #4caf50, #2e7d32);
    color: #fff;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
}

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

.play-btn:disabled {
    background: #555;
    box-shadow: none;
    cursor: not-allowed;
}

.stop-btn {
    background: linear-gradient(135deg, #757575, #424242);
    color: #fff;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

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

.stop-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-icon {
    font-size: var(--font-lg);
}

/* --- Chat Area --- */
.chat-area {
    background: #0a0a1a;
    border-radius: 16px;
    border: 2px solid #2a2a3e;
    padding: 12px;
    display: flex;
    flex-direction: column;
    max-height: 250px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 80px;
    max-height: 160px;
}

.chat-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    max-width: 85%;
    font-size: var(--font-md);
    line-height: 1.5;
    word-break: break-word;
}

.chat-bubble.user {
    align-self: flex-end;
    background: var(--accent-blue);
    color: #fff;
}

.chat-bubble.assistant {
    align-self: flex-start;
    background: #2a2a3e;
    color: var(--text-primary);
}

.chat-input-row {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border-radius: 12px;
    border: 2px solid #2a2a3e;
    background: #1a1a2e;
    color: #fff;
    font-size: var(--font-md);
    outline: none;
}

.chat-input:focus {
    border-color: var(--accent-blue);
}

.chat-send-btn {
    padding: 12px 20px;
    border-radius: 12px;
    border: none;
    background: var(--accent-blue);
    color: #fff;
    font-size: var(--font-md);
    font-weight: bold;
    cursor: pointer;
}

/* --- Bottom Nav --- */
.bottom-nav {
    display: flex;
    border-top: 1px solid #2a2a3e;
    background: rgba(0,0,0,0.3);
}

.nav-btn {
    flex: 1;
    padding: 14px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
}

.nav-btn.active {
    color: var(--accent-gold);
}

.nav-icon {
    font-size: 1.4rem;
}

.nav-label {
    font-size: var(--font-sm);
}

/* --- Settings Panel --- */
.settings-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    z-index: 10;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.settings-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: rgba(0,0,0,0.3);
    border-bottom: 1px solid #2a2a3e;
    position: sticky;
    top: 0;
    z-index: 1;
}

.settings-header h2 {
    font-size: var(--font-xl);
    color: var(--accent-gold);
}

.back-btn {
    background: none;
    border: none;
    color: var(--accent-blue);
    font-size: var(--font-lg);
    cursor: pointer;
    padding: 8px;
}

.settings-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.settings-section {
    background: #0a0a1a;
    border-radius: 16px;
    padding: 20px;
    border: 1px solid #2a2a3e;
}

.settings-section h3 {
    font-size: var(--font-lg);
    color: var(--accent-gold);
    margin-bottom: 16px;
}

.voice-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.voice-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #1a1a2e;
    border-radius: 10px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.voice-item:hover {
    border-color: var(--accent-gold);
}

.voice-item.selected {
    border-color: var(--accent-green);
    background: #1a2a1a;
}

.voice-item-name {
    font-size: var(--font-md);
    font-weight: bold;
}

.voice-item-desc {
    font-size: var(--font-sm);
    color: var(--text-secondary);
}

.preset-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.preset-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: #1a1a2e;
    border-radius: 10px;
}

.preset-info {
    flex: 1;
}

.preset-name {
    font-size: var(--font-md);
    font-weight: bold;
}

.preset-desc {
    font-size: var(--font-sm);
    color: var(--text-secondary);
}

.preset-price {
    font-size: var(--font-md);
    color: var(--accent-gold);
    font-weight: bold;
    margin-right: 12px;
}

.buy-btn {
    padding: 8px 20px;
    border-radius: 8px;
    border: none;
    background: var(--accent-gold);
    color: #000;
    font-weight: bold;
    font-size: var(--font-md);
    cursor: pointer;
}

.settings-btn {
    width: 100%;
    padding: 14px;
    border-radius: 10px;
    border: none;
    background: var(--accent-blue);
    color: #fff;
    font-size: var(--font-md);
    font-weight: bold;
    cursor: pointer;
    margin-top: 8px;
}

.config-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.config-form label {
    font-size: var(--font-sm);
    color: var(--text-secondary);
}

.config-form input {
    padding: 12px;
    border-radius: 8px;
    border: 2px solid #2a2a3e;
    background: #1a1a2e;
    color: #fff;
    font-size: var(--font-md);
    outline: none;
}

.config-form input:focus {
    border-color: var(--accent-blue);
}

.hint-text {
    color: var(--text-secondary);
    font-size: var(--font-sm);
    text-align: center;
    padding: 20px;
}

/* --- Recording Overlay --- */
.recording-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.recording-indicator {
    text-align: center;
}

.recording-pulse {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    border-radius: 50%;
    background: var(--accent-red);
    animation: pulse 1.2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.8); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.7; }
    100% { transform: scale(0.8); opacity: 1; }
}

.recording-text {
    font-size: var(--font-xl);
    color: #fff;
    margin-bottom: 24px;
}

.recording-cancel {
    padding: 12px 30px;
    border-radius: 12px;
    border: 2px solid #fff;
    background: transparent;
    color: #fff;
    font-size: var(--font-md);
    cursor: pointer;
}

/* --- Responsive --- */
@media (max-width: 360px) {
    .knob {
        width: 80px;
        height: 80px;
    }
    .ptt-button {
        width: 80px;
        height: 80px;
    }
    .knob-inner {
        width: 48px;
        height: 48px;
    }
}
