/* 写信页面专属样式，承接home.css的root变量 */

.subpage-main {
    padding-top: 100px;
    min-height: calc(100vh - 100px);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 写信区域样式 */
.letter-container {
    max-width: 800px;
    width: 90%;
    margin: 0 auto 40px auto;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.6s ease forwards;
    box-sizing: border-box;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.letter-form {
    background-color: var(--paper-color);
    padding: 60px 50px 80px;
    border-radius: 4px;
    box-shadow: -10px 10px 30px rgba(162, 142, 124, 0.1), 
                0 0 0 1px rgba(234, 221, 211, 0.5) inset;
    position: relative;
    min-height: 500px;
    /* 信纸专属横线 */
    background-image: repeating-linear-gradient(transparent, transparent 39px, var(--line-color) 39px, var(--line-color) 40px);
    background-position: 0 45px;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.letter-form:hover {
    transform: translateY(-2px);
    box-shadow: -15px 15px 40px rgba(162, 142, 124, 0.15), 
                0 0 0 1px rgba(234, 221, 211, 0.6) inset;
}

/* 左侧红线 - 模仿真实信纸边界 */
.letter-form::after {
    content: '';
    position: absolute;
    top: 0;
    left: 45px;
    height: 100%;
    width: 1px;
    background-color: rgba(255, 184, 34, 0.2);
    pointer-events: none;
}

.letter-header {
    position: absolute;
    top: 25px;
    right: 50px;
    color: var(--text-muted);
    font-size: 14px;
    letter-spacing: 1px;
    z-index: 2;
}

/* 文本区域 */
textarea {
    width: 100%;
    min-height: 380px;
    margin-top: 0;
    padding: 2px 0 20px 20px; /* 留出左侧红线的空间 */
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 17px;
    line-height: 40px; /* 严格对齐信纸横线 */
    color: var(--text-main);
    resize: vertical;
    position: relative;
    z-index: 2;
    box-sizing: border-box;
}

textarea:focus {
    outline: none;
}

textarea::placeholder {
    color: #c7bcae;
    opacity: 0.8;
}

/* 底部操作区 */
.letter-footer {
    position: absolute;
    bottom: -28px;
    right: 40px;
    z-index: 10;
}

.api-button {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent-color);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 6px 15px rgba(255, 184, 34, 0.3);
    border: none;
    cursor: pointer;
}

.api-button:hover {
    transform: translateY(-3px) scale(1.05);
    background: var(--accent-hover);
    box-shadow: 0 8px 20px rgba(255, 184, 34, 0.4);
}

.button-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: -2px;
}

/* 弹窗基础样式 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(253, 251, 247, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.4s ease;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex !important;
    opacity: 1;
}

.modal-content {
    background: var(--paper-color);
    padding: 30px 40px;
    border-radius: 8px;
    width: 90%;
    max-width: 380px;
    transform: translateY(20px);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 20px 40px rgba(138, 115, 95, 0.15), 0 0 0 1px rgba(220, 210, 200, 0.5);
    display: flex;
    flex-direction: column;
    gap: 18px;
    text-align: center;
}

.show .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--line-color);
}

.modal-header h3 {
    font-size: 18px;
    color: var(--text-main);
    margin: 0;
    font-weight: 500;
}

.close-button {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.3s ease;
}

.close-button:hover {
    color: var(--accent-color);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}

.inline-flex-form {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

.form-group label {
    font-size: 14px;
    color: var(--text-main);
}

.modal-input {
    padding: 10px 15px;
    border: 1px solid #dcd1c7;
    background: #fffdfa;
    border-radius: 4px;
    font-size: 14px;
    color: var(--text-main);
    transition: all 0.3s ease;
    font-family: inherit;
}

.modal-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(255, 184, 34, 0.1);
}

.hint {
    font-size: 12px;
    color: var(--text-muted);
    text-align: left;
}

/* Switch Toggle 组件 */
.toggle-switch {
    display: flex;
    align-items: center;
    position: relative;
    width: 44px;
}

.toggle-switch input[type="checkbox"] {
    display: none;
}

.toggle-label {
    width: 44px;
    height: 24px;
    background-color: #dcd1c7;
    border-radius: 20px;
    cursor: pointer;
    position: relative;
    transition: background-color 0.3s ease;
}

.toggle-label::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

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

.toggle-switch input[type="checkbox"]:checked + .toggle-label::after {
    transform: translateX(20px);
}

/* 弹窗底部操作按钮 */
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--line-color);
}

.modal-button {
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.modal-button.cancel {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid #dcd1c7;
}

.modal-button.cancel:hover {
    background: #f6efe9;
    color: var(--text-main);
}

.modal-button.confirm {
    background: var(--accent-color);
    color: white;
    border: none;
    box-shadow: 0 4px 10px rgba(255, 184, 34, 0.2);
}

.modal-button.confirm:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(255, 184, 34, 0.3);
}

.blur {
    filter: blur(4px);
    transition: filter 0.3s ease;
}

/* 移动端适配 */
@media (max-width: 600px) {
    .subpage-main {
        padding-top: 80px;
    }
    
    .letter-form {
        padding: 50px 30px 60px;
        background-position: 0 45px;
    }

    .letter-form::after {
        left: 25px;
    }

    textarea {
        padding-left: 10px;
    }

    .letter-footer {
        right: 25px;
        bottom: -25px;
    }
    
    .api-button {
        width: 50px;
        height: 50px;
    }
}
