/* ==================== 前台显示样式 - 修复悬停问题 ==================== */

/* Top Right Button Container */
#mtrb-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Login Button Styles */
.mtrb-login-button {
    display: inline-block;
    padding: 8px 16px;
    background-color: #0073aa;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.3s ease;
}

.mtrb-login-button:hover {
    background-color: #005a87;
    color: white;
    text-decoration: none;
}

/* Avatar Dropdown Container - 修复悬停区域 */
.mtrb-avatar-dropdown {
    position: relative;
    display: inline-block;
    /* 扩大悬停区域，避免鼠标移动时失去焦点 */
    padding-bottom: 8px; /* 这个很重要，填补空隙 */
}

/* Avatar Container with Role Badge */
.mtrb-avatar-container {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 20px;
    background-color: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.mtrb-avatar-container:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transform: translateY(-1px);
}

/* Avatar Styles */
.mtrb-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #ddd;
    transition: border-color 0.3s ease;
}

.mtrb-avatar-container:hover .mtrb-avatar {
    border-color: #0073aa;
}

/* Role Badge Styles */
.mtrb-role-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Role-specific colors */
.mtrb-role-admin {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
}

.mtrb-role-premium {
    background: linear-gradient(135deg, #f39c12, #e67e22);
}

.mtrb-role-annual {
    background: linear-gradient(135deg, #3498db, #2980b9);
}

.mtrb-role-vip {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
}

.mtrb-role-lifetime {
    background: linear-gradient(135deg, #1abc9c, #16a085);
}

.mtrb-role-subscriber {
    background: linear-gradient(135deg, #95a5a6, #7f8c8d);
}

.mtrb-role-editor {
    background: linear-gradient(135deg, #27ae60, #229954);
}

.mtrb-role-author {
    background: linear-gradient(135deg, #f1c40f, #f39c12);
}

.mtrb-role-contributor {
    background: linear-gradient(135deg, #34495e, #2c3e50);
}

.mtrb-role-default {
    background: linear-gradient(135deg, #bdc3c7, #95a5a6);
}

/* Dropdown Content - 关键修复 */
.mtrb-dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 0; /* 移除间隙！重要修复 */
    background-color: white;
    min-width: 160px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    z-index: 1000000;
    border: 1px solid #ddd;
    overflow: hidden;
    /* 添加向上的小箭头效果（可选） */
    padding-top: 8px;
}

/* 添加一个小箭头指向头像 */
.mtrb-dropdown-content::before {
    content: '';
    position: absolute;
    top: -8px;
    right: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid white;
    z-index: 1000001;
}

/* 箭头的边框 */
.mtrb-dropdown-content::after {
    content: '';
    position: absolute;
    top: -9px;
    right: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid #ddd;
    z-index: 1000000;
}

.mtrb-dropdown-content a {
    color: #333;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    font-size: 14px;
    transition: background-color 0.3s ease;
    position: relative;
    z-index: 1000002;
}

.mtrb-dropdown-content a:hover {
    background-color: #f8f9fa;
    color: #0073aa;
}

/* 修复的悬停逻辑 - 关键！ */
.mtrb-avatar-dropdown:hover .mtrb-dropdown-content {
    display: block;
}

/* 额外保护：当鼠标在下拉菜单上时也保持显示 */
.mtrb-dropdown-content:hover {
    display: block;
}

/* Responsive Design */
@media (max-width: 768px) {
    #mtrb-container {
        top: 10px;
        right: 10px;
    }
    
    .mtrb-avatar-dropdown {
        padding-bottom: 6px;
    }
    
    .mtrb-avatar-container {
        padding: 2px 6px;
        gap: 6px;
    }
    
    .mtrb-avatar {
        width: 28px;
        height: 28px;
    }
    
    .mtrb-role-badge {
        font-size: 11px;
        padding: 1px 6px;
    }
    
    .mtrb-dropdown-content {
        min-width: 140px;
    }
    
    .mtrb-dropdown-content a {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .mtrb-dropdown-content::before {
        right: 15px;
    }
    
    .mtrb-dropdown-content::after {
        right: 15px;
    }
}

/* ==================== 个人资料页面样式 ==================== */

.mtrb-profile-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.mtrb-profile-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

.mtrb-profile-header h2 {
    color: #333;
    margin-bottom: 10px;
    font-size: 28px;
}

.mtrb-profile-header p {
    color: #666;
    font-size: 16px;
    margin: 0;
}

/* 消息提示样式 */
.mtrb-message {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 5px;
    font-size: 14px;
}

.mtrb-message-success {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.mtrb-message-error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.mtrb-message ul {
    margin: 5px 0 0 0;
    padding-left: 20px;
}

/* 表单样式 */
.mtrb-profile-form {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.mtrb-profile-section {
    padding: 25px;
    border-bottom: 1px solid #f0f0f0;
}

.mtrb-profile-section:last-of-type {
    border-bottom: none;
}

.mtrb-profile-section h3 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 20px;
    font-weight: 600;
}

/* 头像设置区域 */
.mtrb-avatar-section {
    display: flex;
    align-items: flex-start;
    gap: 30px;
    flex-wrap: wrap;
}

.mtrb-current-avatar {
    display: flex;
    align-items: center;
    gap: 15px;
}

.mtrb-profile-avatar {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    border: 4px solid #f0f0f0;
    object-fit: cover;
    transition: border-color 0.3s ease;
}

.mtrb-profile-avatar:hover {
    border-color: #0073aa;
}

.mtrb-avatar-info p {
    margin: 5px 0;
    font-size: 14px;
}

.mtrb-avatar-source {
    color: #666;
    font-style: italic;
}

.mtrb-avatar-upload {
    flex: 1;
    min-width: 300px;
}

.mtrb-avatar-upload label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.mtrb-avatar-upload input[type="file"] {
    width: 100%;
    padding: 10px;
    border: 2px dashed #ddd;
    border-radius: 5px;
    background: #fafafa;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.mtrb-avatar-upload input[type="file"]:hover {
    border-color: #0073aa;
    background: #f0f8ff;
}

.mtrb-upload-info {
    margin: 8px 0 0 0;
    font-size: 12px;
    color: #666;
}

/* 表单组样式 */
.mtrb-form-group {
    margin-bottom: 20px;
}

.mtrb-form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.mtrb-form-control {
    width: 100%;
    max-width: 400px;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.mtrb-form-control:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.mtrb-readonly-field {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 5px;
    color: #666;
    max-width: 400px;
}

.mtrb-readonly-note {
    font-size: 12px;
    color: #999;
    font-style: italic;
}

.mtrb-form-help {
    margin: 5px 0 0 0;
    font-size: 12px;
    color: #666;
}

/* 会员信息区域 */
.mtrb-membership-info {
    display: flex;
    align-items: flex-start;
    gap: 30px;
    flex-wrap: wrap;
}

.mtrb-membership-badge {
    text-align: center;
}

.mtrb-large-badge {
    padding: 8px 20px;
    font-size: 16px;
    font-weight: 700;
    border-radius: 20px;
}

.mtrb-membership-details {
    flex: 1;
    min-width: 300px;
}

.mtrb-membership-details p {
    margin: 10px 0;
    font-size: 14px;
    line-height: 1.5;
}

/* 按钮样式 */
.mtrb-form-actions {
    padding: 25px;
    background: #f8f9fa;
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.mtrb-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-block;
    text-align: center;
    min-width: 120px;
}

.mtrb-btn-primary {
    background: #0073aa;
    color: white;
}

.mtrb-btn-primary:hover {
    background: #005a87;
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 115, 170, 0.3);
}

.mtrb-btn-secondary {
    background: #6c757d;
    color: white;
}

.mtrb-btn-secondary:hover {
    background: #545b62;
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(108, 117, 125, 0.3);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .mtrb-profile-container {
        padding: 15px;
    }
    
    .mtrb-profile-section {
        padding: 20px 15px;
    }
    
    .mtrb-avatar-section,
    .mtrb-membership-info {
        flex-direction: column;
        gap: 20px;
    }
    
    .mtrb-current-avatar {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
    
    .mtrb-profile-avatar {
        width: 120px;
        height: 120px;
    }
    
    .mtrb-form-control,
    .mtrb-readonly-field {
        max-width: 100%;
    }
    
    .mtrb-form-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .mtrb-btn {
        width: 100%;
    }
}

/* 错误状态样式 */
.mtrb-profile-error {
    text-align: center;
    padding: 40px 20px;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 5px;
    color: #721c24;
    font-size: 16px;
}

/* ==================== 后台管理界面样式 ==================== */

/* 角色配置页面样式 */
.mtrb-role-table {
    margin-top: 20px;
}

.mtrb-role-table th,
.mtrb-role-table td {
    padding: 15px 10px;
    vertical-align: middle;
}

.mtrb-role-table th {
    background-color: #f9f9f9;
    font-weight: 600;
}

.mtrb-role-table tbody tr:nth-child(even) {
    background-color: #fafafa;
}

.mtrb-role-table tbody tr:hover {
    background-color: #f0f8ff;
}

/* 开关样式 */
.mtrb-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.mtrb-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.mtrb-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.mtrb-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .mtrb-slider {
    background-color: #0073aa;
}

input:focus + .mtrb-slider {
    box-shadow: 0 0 1px #0073aa;
}

input:checked + .mtrb-slider:before {
    transform: translateX(26px);
}

/* 颜色选择器样式 */
.mtrb-color-select {
    width: 140px;
    padding: 5px;
    border-radius: 4px;
    border: 1px solid #ddd;
}

/* 预览徽章样式 */
.mtrb-preview-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    display: inline-block;
}

/* 操作按钮区域 */
.mtrb-actions {
    margin-top: 20px;
    padding: 20px 0;
    border-top: 1px solid #ddd;
}

.mtrb-actions .button {
    margin-right: 10px;
}

/* 帮助说明区域 */
.mtrb-help-section {
    margin-top: 30px;
    padding: 20px;
    background-color: #f8f9fa;
    border-left: 4px solid #0073aa;
    border-radius: 4px;
}

.mtrb-help-section h3 {
    margin-top: 0;
    color: #0073aa;
}

.mtrb-help-section ul {
    margin: 15px 0;
    padding-left: 20px;
}

.mtrb-help-section li {
    margin-bottom: 8px;
    line-height: 1.5;
}

/* 导航标签样式增强 */
.nav-tab-wrapper {
    margin-bottom: 20px;
}

.nav-tab {
    transition: all 0.3s ease;
}

.nav-tab:hover {
    background-color: #f0f8ff;
}

/* Admin Settings Preview */
.mtrb-role-preview .mtrb-role-badge {
    margin-right: 10px !important;
    margin-bottom: 5px !important;
    display: inline-block !important;
}

/* 调试信息区域 */
.mtrb-debug-section {
    margin-top: 30px;
    padding: 15px;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.mtrb-debug-section h3 {
    margin-top: 0;
    color: #666;
}

/* 表格响应式 */
@media (max-width: 768px) {
    .mtrb-role-table,
    .mtrb-role-table thead,
    .mtrb-role-table tbody,
    .mtrb-role-table th,
    .mtrb-role-table td,
    .mtrb-role-table tr {
        display: block;
    }
    
    .mtrb-role-table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    
    .mtrb-role-table tr {
        border: 1px solid #ccc;
        margin-bottom: 10px;
        padding: 10px;
    }
    
    .mtrb-role-table td {
        border: none;
        border-bottom: 1px solid #eee;
        position: relative;
        padding-left: 30%;
    }
    
    .mtrb-role-table td:before {
        content: attr(data-label);
        position: absolute;
        left: 6px;
        width: 25%;
        padding-right: 10px;
        white-space: nowrap;
        font-weight: bold;
    }
}

/* 成功/错误消息样式 */
.notice.mtrb-notice {
    border-left-width: 4px;
    padding: 12px;
}

.notice.mtrb-notice.notice-success {
    border-left-color: #46b450;
    background-color: #fff;
}

.notice.mtrb-notice.notice-error {
    border-left-color: #dc3232;
    background-color: #fff;
}