/* ========= 变量定义 ========= */
:root {
    /* 颜色变量 */
    --primary-color: #4a6fa5;
    --primary-hover: #3a5a8f;
    --success-color: #155724;
    --success-bg: #d4edda;
    --error-color: #721c24;
    --error-bg: #f8d7da;
    --light-bg: #f8f9fa;
    --dark-bg: #e9ecef;
    --text-color: #333;
    --text-light: #666;
    --border-color: #e0e0e0;
    --white: #ffffff;
    
    /* 尺寸变量 */
    --border-radius: 8px;
    --border-radius-sm: 4px;
    --box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    --box-shadow-lg: 0 0 20px rgba(0, 0, 0, 0.2);
    
    /* 过渡效果 */
    --transition-time: 0.3s;
}

/* ========= 基础样式 ========= */
.memfire-reset-password-container input,
.memfire-reset-password-container button,
.payment-option input,
.payment-option label {
    box-sizing: border-box;
    font-family: inherit;
}

/* ========= 容器样式 ========= */
.memfire-reset-password-container {
    max-width: 600px;
    margin: 2rem auto;
    padding: 2rem;
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

/* ========= 表单元素 ========= */
.memfire-reset-password-container .form-group {
    margin-bottom: 1.5rem;
}

.memfire-reset-password-container label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
    color: var(--text-color);
}

.memfire-reset-password-container .theme-input {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    transition: border-color var(--transition-time);
}

.memfire-reset-password-container .theme-input:focus {
    border-color: var(--primary-color);
    outline: none;
}

/* 只读邮箱显示 */
.email-display {
    margin-bottom: 1.5rem;
}

.readonly-email {
    display: block;
    padding: 0.8rem;
    background-color: var(--light-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    color: var(--text-color);
    margin-top: 0.3rem;
}

/* ========= 按钮样式 ========= */
.theme-button {
    background: var(--primary-color);
    color: var(--white);
    /* padding: 0.8rem 1.5rem; */
    padding: 6px 12px;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 1rem;
    transition: all var(--transition-time) ease;
    text-align: center;
    display: inline-block;
    text-decoration: none;
    /* min-width: 100px; */
    min-width: auto;
}

.theme-button:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.theme-button:active {
    transform: translateY(0);
}

.theme-button.secondary {
    background: var(--dark-bg);
    color: var(--text-color);
}

.theme-button.secondary:hover {
    background: #d1d5db;
}

/* 通知消息样式 */
.notice {
    padding: 1rem;
    margin: 1rem 0;
    border-left: 4px solid;
    border-radius: 3px;
}

.notice-success {
    border-color: #46b450;
    background: rgba(70, 180, 80, 0.1);
}

.notice-error {
    border-color: #dc3232;
    background: rgba(220, 50, 50, 0.1);
}

.notice-warning {
    border-color: #ffb900;
    background: rgba(255, 185, 0, 0.1);
}

/* ========= 消息提示 ========= */
#reset-message {
    margin-top: 1.5rem;
}

#reset-message .success {
    color: var(--success-color);
    background-color: var(--success-bg);
    padding: 0.75rem 1.25rem;
    border-radius: var(--border-radius-sm);
}

#reset-message .error {
    color: var(--error-color);
    background-color: var(--error-bg);
    padding: 0.75rem 1.25rem;
    border-radius: var(--border-radius-sm);
}

/* 密码强度计 */
.password-strength-meter {
    margin-top: 0.5rem;
    font-size: 0.875em;
}

/* ========= 设备管理桌面样式 ========= */
#memfire-device-manager {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    padding: 20px;
    margin: 2rem 0;
}
  
.device-list-section {
    width: 100%;
    overflow-x: auto;
}

#device-list {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}
  
#device-list th {
    background: var(--primary-color);
    color: var(--white);
    padding: 12px 15px;
    text-align: left;
}

#device-list td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

/* 斑马纹效果 */
#device-list tbody tr:nth-child(odd) {
    background-color: rgba(0, 0, 0, 0.02);
}
  
.expiration-dates {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.9em;
}

.expiration-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 0;
    line-height: 1.4;
}

.expiration-label {
    font-weight: 500;
    color: var(--text-light);
    margin-right: 8px;
    white-space: nowrap;
}

.expiration-value {
    font-family: monospace;
    color: var(--text-color);
    min-width: 80px;
    text-align: right;
}

.action-buttons {
    display: flex;
    gap: 8px;
}

.pay-device-btn,
.delete-device-btn {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* ========= 模态框统一样式 ========= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
}

.modal-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-lg);
    padding: 0;
    z-index: 1000;
    max-height: 80vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 15px 10px;
    margin: 0;
    background: var(--primary-color);
    color: var(--white);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    font-size: 1.1rem;
    cursor: move;
    user-select: none;
}

.modal-body {
    padding: 10px 10px;
    flex-grow: 1;
    overflow-y: auto;
}

.modal-footer {
    padding: 0px 10px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* 按钮容器 */
.button-container {
    display: flex;
    justify-content: flex-end;
    /* padding: 15px 20px; */
    padding: 10px 0px;
    background: var(--white);
    border-top: 1px solid var(--border-color);
    position: sticky;
    bottom: 0;
    gap: 10px;
}

/* ========= 状态消息统一样式 ========= */
.status-message {
    margin: 10px 0;
    padding: 12px 0px;
    border-radius: 4px;
    display: none;
    position: relative;
    padding-left: 40px;
    font-size: 0.9em;
}

.status-message:before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    border-radius: 4px 0 0 4px;
}

.status-message.success {
    background-color: #f0fdf4;
    color: #166534;
    display: block;
}

.status-message.success:before {
    background-color: #22c55e;
}

.status-message.error {
    background-color: #fef2f2;
    color: #991b1b;
    display: block;
}

.status-message.error:before {
    background-color: #ef4444;
}

/* 付费选项模态框特定样式 */
#custom-payment-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--white);
    padding: 0; /* 改为内部元素控制间距 */
    box-shadow: var(--box-shadow-lg);
    z-index: 1000;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 500px;
    max-height: 80vh; /* 限制最大高度 */
    display: flex;
    flex-direction: column;
    overflow: hidden; /* 隐藏内部滚动条 */
    cursor: default;
}

#custom-payment-container h3 {
    background-color: var(--primary-color);
    color: var(--white);
    padding: 15px 20px;
    margin: 0;
    font-size: 1.1rem;
    cursor: move;
    user-select: none;
    position: sticky;
    top: 0;
    z-index: 1;
}

#payment-content {
    padding: 20px;
    overflow-y: auto; /* 启用垂直滚动 */
    flex-grow: 1;
}

#payment-options {
    max-height: calc(70vh - 150px); /* 预留空间给标题和按钮 */
    overflow-y: auto;
}
/* 单个选项 - 紧凑布局 */
.payment-option {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    margin-bottom: 8px;
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-time) ease;
    border: 1px solid var(--border-color);
    cursor: pointer;
}

/* 选项内容布局 */
.payment-option-content {
    display: flex;
    align-items: center;
    width: 100%;
}

.payment-option:nth-child(odd) {
    background-color: var(--light-bg);
}

.payment-option:nth-child(even) {
    background-color: var(--dark-bg);
}

.payment-option:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-color);
}

.payment-option input[type="radio"] {
    margin-right: 12px;
    accent-color: var(--primary-color);
    flex-shrink: 0;
}

.payment-option label {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    cursor: pointer;
    margin-right: 10px;
}

.payment-option input[type="radio"]:checked + label {
    color: var(--primary-color);
    font-weight: bold;
}

/* 选项文字布局 */
.payment-option-main {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
}

.payment-option-title {
    font-weight: 600;
    color: var(--text-color);
}

.payment-option-price {
    color: var(--primary-color);
    font-weight: bold;
    margin-left: 10px;
}

.payment-description {
    font-size: 0.85em;
    color: var(--text-light);
    line-height: 1.4;
}

/* ========= 交互状态 ========= */
.payment-option:hover {
    border-color: var(--primary-color);
    background-color: rgba(74, 111, 165, 0.05);
}

.payment-option input[type="radio"]:checked ~ label .payment-option-title {
    color: var(--primary-color);
}

.payment-option input[type="radio"]:checked {
    accent-color: var(--primary-color);
}

/* ========= 消息提示框 ========= */
/* #memfire-auth-message-box {
    position: fixed;
    bottom: 20px;
    right: 20px;
    max-width: 350px;
    z-index: 1001;
    transition: all 0.3s ease;
} */

#memfire-auth-message {
    padding: 12px 15px;
    margin: 0;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: relative;
    padding-left: 40px;
}

#memfire-auth-message:before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    border-radius: 4px 0 0 4px;
}

#memfire-auth-message.success {
    background-color: #f0fdf4;
    color: #166534;
}

#memfire-auth-message.success:before {
    background-color: #22c55e;
}

#memfire-auth-message.error {
    background-color: #fef2f2;
    color: #991b1b;
}

#memfire-auth-message.error:before {
    background-color: #ef4444;
}

#memfire-auth-message.info {
    background-color: #eff6ff;
    color: #1e40af;
}

#memfire-auth-message.info:before {
    background-color: #3b82f6;
}

  
/* ========= 移动端响应式样式 ========= */
@media (max-width: 768px) {
    .memfire-reset-password-container {
        padding: 1.5rem;
        margin: 1rem;
    }

    #memfire-device-manager {
        padding: 15px;
        margin: 1rem 0;
    }

    /* 表格转卡片布局 */
    #device-list {
        display: block;
        border: none;
    }

    #device-list thead {
        display: none;
    }

    #device-list tbody tr {
        display: block;
        margin-bottom: 15px;
        border: 1px solid var(--border-color);
        border-radius: var(--border-radius-sm);
        background: var(--white);
        box-shadow: var(--box-shadow);
    }

    #device-list td {
        display: flex;
        justify-content: space-between;
        padding: 12px 15px;
    }

    #device-list td::before {
        content: attr(data-label);
        font-weight: 500;
        color: var(--primary-color);
        margin-right: 10px;
    }

    /* 操作按钮组 */
    .action-buttons {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .pay-device-btn,
    .delete-device-btn {
        width: 100%;
        text-align: center;
    }

    .modal-container .button-container {
        flex-direction: row; /* 保持水平排列 */
        justify-content: flex-end;
        gap: 8px; /* 减小按钮间距 */
    }
    
    .modal-container .theme-button {
        padding: 5px 10px;
        font-size: 0.85rem;
    }

    /* 消息框调整 */
    /* #memfire-auth-message-box {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        width: 90%;
    } */
}
  
/* 超小屏幕优化 (<= 576px) */
/* @media (max-width: 576px) {
#device-list td {
    flex-direction: column;
    gap: 5px;
}

#device-list td::before {
    margin-bottom: 3px;
}

.expiration-dates {
    gap: 8px;
}

.expiration-item {
    flex-wrap: wrap;
}
} */


/* ========= 响应式设计 ========= */
@media (max-width: 768px) {
    .expiration-item {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }
    
    .expiration-label {
        margin-right: 4px;
        margin-bottom: 0;
        font-size: 0.85em;
        flex: 0 0 40%;
        min-width: 100px;
    }
    
    .expiration-value {
        text-align: right;
        flex: 1 1 50%;
        padding-left: 10px;
    }
    
    #device-list {
        font-size: 0.9em;
    }
}

@media (max-width: 500px) {
    #custom-payment-container {
        width: 85%;
        max-height: 90vh;
    }
    #add-device-modal {
        width: 85%;
        max-height: 90vh;
    }
    
    #payment-content {
        padding: 15px;
    }
    
    .payment-option {
        padding: 10px 12px;
    }
    
    /* .button-container {
        flex-direction: column;
    } */
    
    /* .theme-button {
        width: 100%;
    } */
}

/* ====== 添加设备模态框 - 最终优化版 ====== */
#device-sn {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-sizing: border-box;
}

/* 软键盘弹出适配 */
@media (max-height: 600px) {
    #add-device-modal {
        top: 10px;
        transform: translateX(-50%);
        max-height: calc(100vh - 20px);
    }
    #device-sn:focus {
        scroll-margin-top: 100px;
    }
}

/* 防止Android键盘挤压布局 */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    #add-device-modal {
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
    }
}

/* ========= 防止自动填充样式 ========= */
input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text-color) !important;
    -webkit-box-shadow: 0 0 0px 1000px var(--white) inset !important;
}
  
/* ========= 动画效果 ========= */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

#memfire-device-manager {
    animation: fadeIn 0.4s ease-out;
}

.modal-container {
    animation: fadeIn 0.3s ease-out;
}

/* ========= 中文环境优化 ========= */
.lang-zh .expiration-label {
    margin-right: 4px;
}