:root {
    --primary-color: #07C160;
    --primary-dark: #06ad56;
    --secondary-color: #1890ff;
    --success-color: #52c41a;
    --warning-color: #ffba00;
    --danger-color: #ff4d4f;
    --info-color: #17a2b8;
    --light-bg: #f5f7fa;
    --card-bg: #ffffff;
    --text-color: #333;
    --text-secondary: #666;
    --border-color: #e4e6eb;
    --shadow: 0 4px 12px rgba(0,0,0,0.05);
    --radius: 12px;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans SC', sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e6eb 100%);
    min-height: 100vh;
    padding: 20px;
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 25px 30px;
    box-shadow: var(--shadow);
    margin-bottom: 25px;
    background: linear-gradient(to right, #ffffff, #f8f9fa);
    border: 1px solid var(--border-color);
    position: relative;
}

.logo {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
}

.logo i {
    font-size: 38px;
    color: var(--primary-color);
    background: rgba(7, 193, 96, 0.1);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo h1 {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.connection-form {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-end;
}

.form-group {
    flex: 1;
    min-width: 220px;
}

.form-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-group input {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 16px;
    transition: var(--transition);
    background: #fafbfc;
}

.form-group input:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(7, 193, 96, 0.15);
    background: #fff;
}

.btn {
    padding: 14px 28px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 16px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(7, 193, 96, 0.25);
}

.btn-secondary {
    background: #f0f2f5;
    color: var(--text-color);
}

.btn-secondary:hover {
    background: #e4e6e9;
    transform: translateY(-2px);
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-warning:hover {
    background: #e6a800;
    transform: translateY(-2px);
}

.btn-success {
    background: var(--secondary-color);
    color: white;
}

.btn-success:hover {
    background: #1478d4;
    transform: translateY(-2px);
}

.btn-info {
    background: var(--info-color);
    color: white;
}

.btn-info:hover {
    background: #138496;
    transform: translateY(-2px);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.connection-status {
    padding: 12px 18px;
    border-radius: 10px;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    border: 1px solid var(--border-color);
}

.status-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.status-disconnected .status-dot {
    background: var(--danger-color);
}

.status-connected .status-dot {
    background: var(--success-color);
}

.whitelist-notice {
    background: #e6f7ff;
    border: 1px solid #91d5ff;
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    gap: 20px;
    margin-bottom: 25px;
    align-items: flex-start;
    box-shadow: var(--shadow);
}

.whitelist-notice i {
    font-size: 28px;
    color: var(--secondary-color);
    margin-top: 4px;
}

.whitelist-title {
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--secondary-color);
    font-size: 18px;
}

.ip-address {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 15px;
}

.ip-text {
    font-family: monospace;
    font-size: 17px;
    background: #f0f2f5;
    padding: 10px 15px;
    border-radius: 8px;
    border: 1px solid #ddd;
    flex: 1;
}

.copy-btn {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
    font-weight: 500;
}

.copy-btn:hover {
    background: #1478d4;
    transform: translateY(-2px);
}

main {
    display: flex;
    gap: 25px;
    flex-wrap: wrap;
}

.editor-section, .preview-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 25px;
    box-shadow: var(--shadow);
    flex: 1;
    min-width: 320px;
    border: 1px solid var(--border-color);
}

.editor-section {
    flex: 2;
}

.preview-section {
    flex: 1;
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 25px;
}

.section-title h2 {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 22px;
    font-weight: 600;
    color: #444;
}

.menu-stats {
    display: flex;
    gap: 18px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 8px 15px;
    border-radius: 25px;
    font-size: 15px;
    font-weight: 500;
}

.stat-item.primary {
    background: #e6f7ff;
    color: var(--secondary-color);
}

.stat-item.secondary {
    background: #f6ffed;
    color: var(--success-color);
}

.menu-editor {
    background: #f8f9fa;
    border-radius: var(--radius);
    padding: 25px;
    min-height: 450px;
    margin-bottom: 25px;
    border: 1px solid var(--border-color);
}

.menu-level {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.menu-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    width: 220px;
    cursor: move;
    transition: var(--transition);
    box-shadow: 0 3px 6px rgba(0,0,0,0.04);
}

.menu-item:hover {
    box-shadow: 0 6px 12px rgba(0,0,0,0.08);
    border-color: #d0d5dd;
    transform: translateY(-3px);
}

.menu-item.active {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(24, 144, 255, 0.15);
    background: #f8fbff;
}

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

.menu-name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 16px;
}

.menu-actions {
    display: flex;
    gap: 6px;
}

.menu-actions button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.menu-actions button:hover {
    background: #f0f2f5;
    color: var(--text-color);
    transform: scale(1.1);
}

.submenu-container {
    margin-top: 15px;
}

.submenu-item {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 10px 15px;
    margin-bottom: 8px;
    font-size: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
    border: 1px solid var(--border-color);
}

.submenu-item:hover {
    background: #f0f2f5;
}

.submenu-item.active {
    background: #e6f7ff;
    border: 1px solid #91d5ff;
}

.menu-config {
    margin-top: 25px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 25px;
    background: var(--card-bg);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.config-title {
    margin-top: 0;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    color: #444;
}

.form-row {
    margin-bottom: 20px;
}

.form-row label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-row input, .form-row select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    transition: var(--transition);
    background: #fafbfc;
}

.form-row input:focus, .form-row select:focus {
    border-color: var(--secondary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(24, 144, 255, 0.15);
    background: #fff;
}

.hint {
    color: #999;
    font-weight: normal;
    font-size: 13px;
    margin-top: 4px;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 25px;
}

.phone-preview {
    background: linear-gradient(135deg, #1a1a1a 0%, #000000 100%);
    width: 100%;
    max-width: 320px;
    height: 640px;
    border-radius: 40px;
    padding: 25px;
    margin: 0 auto;
    position: relative;
    box-shadow: 0 15px 30px rgba(0,0,0,0.2);
}

.phone-notch {
    width: 45%;
    height: 25px;
    background: #000;
    border-radius: 0 0 15px 15px;
    position: absolute;
    top: 0;
    left: 27.5%;
    z-index: 10;
}

.phone-screen {
    background: #f0f2f5;
    height: 100%;
    border-radius: 25px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
}

.wechat-header {
    background: var(--primary-color);
    color: white;
    text-align: center;
    padding: 18px;
    font-weight: 600;
    font-size: 19px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.preview-content {
    flex: 1;
    padding: 25px;
    position: relative;
    background: linear-gradient(to bottom, #f5f7fa, #e4e6eb);
}

.empty-state {
    text-align: center;
    color: #999;
    padding: 50px 25px;
}

.empty-state i {
    font-size: 56px;
    margin-bottom: 20px;
    color: #d0d5dd;
    opacity: 0.7;
}

.empty-state h3 {
    font-size: 20px;
    margin-bottom: 10px;
    color: #666;
}

.empty-state p {
    font-size: 15px;
}

.wechat-menu {
    display: flex;
    height: 55px;
    background: white;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -2px 5px rgba(0,0,0,0.05);
}

.menu-preview-item {
    flex: 1;
    text-align: center;
    padding: 17px 0;
    position: relative;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: var(--transition);
}

.menu-preview-item:hover {
    background: #f8f8f8;
}

.menu-preview-item.has-submenu::after {
    content: "▼";
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    color: #999;
}

.submenu-preview {
    display: none;
    position: absolute;
    bottom: 55px;
    left: 0;
    right: 0;
    background: white;
    padding: 12px;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    box-shadow: 0 -4px 15px rgba(0,0,0,0.1);
    border-top-left-radius: 15px;
    border-top-right-radius: 15px;
    z-index: 5;
}

.submenu-preview-item {
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
    text-align: center;
    font-size: 14px;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.submenu-preview-item:hover {
    background: #f0f2f5;
    transform: translateY(-2px);
}

#toast-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.toast {
    background: white;
    border-radius: var(--radius);
    padding: 20px 25px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 10px;
    transform: translateX(100px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    min-width: 300px;
    position: relative;
    overflow: hidden;
    border-left: 5px solid;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast i {
    font-size: 24px;
}

.toast .toast-content {
    flex: 1;
}

.toast .toast-title {
    font-weight: 600;
    margin-bottom: 5px;
    font-size: 16px;
}

.toast .toast-message {
    font-size: 14px;
    color: #555;
}

.toast-success {
    border-left-color: var(--success-color);
}

.toast-success i {
    color: var(--success-color);
}

.toast-error {
    border-left-color: var(--danger-color);
}

.toast-error i {
    color: var(--danger-color);
}

.toast-warning {
    border-left-color: var(--warning-color);
}

.toast-warning i {
    color: var(--warning-color);
}

.toast-info {
    border-left-color: var(--info-color);
}

.toast-info i {
    color: var(--info-color);
}

.progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 5px;
    background: rgba(0,0,0,0.1);
    width: 100%;
    border-radius: 0 0 var(--radius) var(--radius);
    overflow: hidden;
}

.progress-bar::after {
    content: '';
    display: block;
    height: 100%;
    width: 100%;
    background: currentColor;
    animation: progress 3s linear forwards;
}

@keyframes progress {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

/* 模态框样式 */
.modal {
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: #fff;
    border-radius: var(--radius);
    width: 90%;
    max-width: 500px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    overflow: hidden;
}

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

.modal-header h3 {
    margin: 0;
    font-size: 20px;
}

.close {
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    color: #999;
}

.close:hover {
    color: #000;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 15px;
}

#template-name {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
}

.template-list {
    max-height: 300px;
    overflow-y: auto;
}

.template-item {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
}

.template-item:hover {
    background-color: #f5f7fa;
}

.template-item:last-child {
    border-bottom: none;
}

.template-name {
    font-weight: 600;
    margin-bottom: 5px;
}

.template-date {
    font-size: 14px;
    color: #999;
}

/* 加载动画 */
.loader {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 移动端优化 */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 10px;
    }
    
    header {
        padding: 15px 20px;
    }
    
    .logo {
        margin-bottom: 15px;
    }
    
    .logo i {
        font-size: 28px;
        width: 45px;
        height: 45px;
    }
    
    .logo h1 {
        font-size: 22px;
    }
    
    .connection-form {
        gap: 15px;
    }
    
    .form-group {
        min-width: 100%;
    }
    
    .editor-section, .preview-section {
        padding: 15px;
    }
    
    .menu-editor {
        padding: 15px;
        min-height: 350px;
    }
    
    .menu-item {
        width: 100%;
        max-width: 100%;
    }
    
    .phone-preview {
        max-width: 260px;
        height: 520px;
        padding: 15px;
    }
    
    .section-title h2 {
        font-size: 18px;
    }
    
    #toast-container {
        bottom: 15px;
        right: 15px;
        left: 15px;
    }
    
    .toast {
        min-width: auto;
        width: 100%;
    }
    
    .actions {
        flex-direction: column;
    }
    
    .actions button {
        width: 100%;
    }
}

/* 平板优化 */
@media (min-width: 769px) and (max-width: 1024px) {
    .menu-item {
        width: calc(50% - 10px);
    }
    
    .actions {
        gap: 10px;
    }
    
    .actions button {
        flex: 1;
        min-width: 120px;
    }
}

/* 动画效果 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.menu-item, .submenu-item, .btn {
    animation: fadeIn 0.3s ease-out;
}

/* 自定义滚动条 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}