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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

/* 头部样式 */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* 主体内容 */
main {
    padding: 40px 30px;
}

/* 翻译区域 */
.translator-section {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.input-panel,
.output-panel {
    display: flex;
    flex-direction: column;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.panel-header h2 {
    font-size: 1.3rem;
    color: #667eea;
}

.header-actions {
    display: flex;
    gap: 10px;
}

textarea {
    width: 100%;
    min-height: 200px;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1rem;
    font-family: 'Courier New', monospace;
    resize: vertical;
    transition: border-color 0.3s;
}

textarea:focus {
    outline: none;
    border-color: #667eea;
}

#morseOutput {
    font-size: 1.2rem;
    letter-spacing: 2px;
}

/* 按钮样式 */
button {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.clear-btn {
    background-color: #f44336;
    color: white;
}

.clear-btn:hover {
    background-color: #d32f2f;
    transform: translateY(-2px);
}

.copy-btn {
    background-color: #2196F3;
    color: white;
}

.copy-btn:hover {
    background-color: #1976D2;
    transform: translateY(-2px);
}

.swap-btn {
    background-color: #667eea;
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    align-self: center;
}

.swap-btn:hover {
    background-color: #764ba2;
    transform: rotate(180deg);
}

.swap-btn svg {
    width: 24px;
    height: 24px;
}

/* 转换区域 */
.convert-section {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 控制面板 */
.control-panel {
    background-color: #f5f5f5;
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px;
}

.control-item {
    display: flex;
    align-items: center;
    gap: 15px;
}

.control-item label {
    font-weight: 500;
    color: #555;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

#speedControl {
    width: 200px;
    height: 8px;
    border-radius: 5px;
    outline: none;
    -webkit-appearance: none;
    background: #ddd;
}

#speedControl::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
}

#speedControl::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
}

#speedValue {
    font-weight: 700;
    color: #667eea;
    min-width: 30px;
}

/* Playback Controls */
.playback-controls {
    display: flex;
    gap: 15px;
    align-items: center;
}

.control-btn {
    width: 100px;
    height: 100px;
    border-radius: 16px;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.control-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.control-btn:active:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.control-btn svg {
    width: 32px;
    height: 32px;
}

.control-btn span {
    font-size: 0.85rem;
}

/* Play Button - Green */
.play-btn {
    background: linear-gradient(135deg, #81c784 0%, #66bb6a 100%);
    color: white;
}

.play-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #66bb6a 0%, #4caf50 100%);
}

/* Pause Button - Blue */
.pause-btn {
    background: linear-gradient(135deg, #64b5f6 0%, #42a5f5 100%);
    color: white;
}

.pause-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #42a5f5 0%, #2196f3 100%);
}

/* Stop Button - Red/Coral */
.stop-btn {
    background: linear-gradient(135deg, #ef9a9a 0%, #e57373 100%);
    color: white;
}

.stop-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #e57373 0%, #ef5350 100%);
}

/* Repeat Button - Gray/White */
.repeat-btn {
    background: linear-gradient(135deg, #ffffff 0%, #f5f5f5 100%);
    color: #666;
    border: 2px solid #e0e0e0;
}

.repeat-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #f5f5f5 0%, #eeeeee 100%);
    color: #333;
}

.repeat-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
}

.repeat-btn.active:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

/* 对照表 */
.reference-section {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px solid #e0e0e0;
}

.reference-section h3 {
    font-size: 1.5rem;
    color: #667eea;
    margin-bottom: 20px;
    text-align: center;
}

.morse-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
}

.morse-item {
    background-color: #f5f5f5;
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    transition: all 0.3s;
}

.morse-item:hover {
    background-color: #667eea;
    color: white;
    transform: translateY(-3px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.morse-item .char {
    display: block;
    font-weight: 700;
    font-size: 1.2rem;
    margin-bottom: 5px;
}

.morse-item .code {
    display: block;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

/* 页脚 */
footer {
    background-color: #f5f5f5;
    padding: 20px;
    text-align: center;
    color: #666;
    font-size: 0.9rem;
}

/* 响应式设计 */
@media (max-width: 968px) {
    .translator-section {
        grid-template-columns: 1fr;
    }

    .convert-section {
        order: -1;
        margin: 20px 0;
    }

    .swap-btn {
        transform: rotate(90deg);
    }

    .swap-btn:hover {
        transform: rotate(270deg);
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    main {
        padding: 30px 20px;
    }

    .control-panel {
        flex-direction: column;
        align-items: stretch;
    }

    .control-item {
        flex-direction: column;
        align-items: stretch;
    }

    #speedControl {
        width: 100%;
    }

    .playback-controls {
        justify-content: center;
        flex-wrap: wrap;
    }

    .control-btn {
        width: 90px;
        height: 90px;
    }

    .morse-grid {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
        gap: 8px;
    }

    .play-btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    .container {
        border-radius: 10px;
    }

    header {
        padding: 30px 20px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    textarea {
        min-height: 150px;
        font-size: 0.9rem;
    }

    .morse-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 6px;
    }

    .morse-item {
        padding: 8px;
    }

    .morse-item .char {
        font-size: 1rem;
    }

    .morse-item .code {
        font-size: 0.8rem;
    }
}
