/* 组件样式 */

/* 模态框样式 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal-overlay.show .modal-content {
    transform: scale(1);
}

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

.modal-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 20px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px;
}

.modal-body {
    padding: 20px 24px;
}

.modal-footer {
    padding: 16px 24px 24px 24px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* 消息提示 */
.toast {
    position: fixed;
    top: 24px;
    right: 24px;
    padding: 16px 24px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

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

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

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

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

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

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

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

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

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

input:checked + .slider {
    background-color: var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(24px);
}

/* 标签页样式 */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--border-color);
}

.tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 12px 20px;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.tab:hover {
    background: var(--hover-bg);
    color: var(--text-color);
}

.tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: var(--card-bg);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* 状态徽章 */
.status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 500;
}

.status-badge.status-active {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.status-disabled {
    background: #fee2e2;
    color: #991b1b;
}

/* 代码块样式 */
.code-block {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
    font-family: monospace;
    margin: 10px 0;
    font-size: 14px;
}

.code-block h5 {
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.9em;
    font-weight: 600;
}

.code-block code {
    display: inline-block;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: var(--primary-color);
}

.code-block pre {
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
    line-height: 1.5;
    overflow-x: auto;
    color: #2d3748;
    margin: 0;
}

/* 变量表格样式 */
.variable-table code {
    background: #e2e8f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
    color: var(--primary-color);
}

/* 测试工具样式 */
.test-tool {
    display: flex;
    gap: 12px;
    align-items: center;
    margin: 16px 0;
    flex-wrap: wrap;
}

.test-result {
    margin-top: 12px;
    padding: 12px;
    border-radius: 6px;
    font-size: 0.9em;
}

.test-result.success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}

.test-result.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

/* 帮助页面样式 */
.help-content {
    padding: 20px;
}

.help-section {
    margin-bottom: 40px;
}

.help-section h4 {
    color: var(--primary-color);
    margin-bottom: 16px;
    font-size: 1.2em;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 8px;
}

.help-section p {
    margin-bottom: 16px;
    color: var(--text-color);
    line-height: 1.6;
}

/* 变量帮助区域 */
.variable-help {
    margin-top: 40px;
    padding: 20px;
    background: var(--card-bg);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.variable-help h5 {
    margin-bottom: 16px;
    color: var(--text-color);
    font-size: 1em;
}

.variable-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.variable-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.variable-item code {
    background: #e2e8f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
    color: var(--primary-color);
    font-weight: 600;
}

.variable-item span {
    color: var(--text-secondary);
    font-size: 0.9em;
}

/* 红色提取按钮样式 */
.extract-btn-red {
    background-color: #dc3545 !important;
    color: white !important;
    border: 1px solid #dc3545 !important;
    font-weight: 600;
}

.extract-btn-red:hover {
    background-color: #c82333 !important;
    border-color: #bd2130 !important;
    color: white !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(220, 53, 69, 0.3);
}

.extract-btn-red:active {
    background-color: #bd2130 !important;
    border-color: #b21e2c !important;
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.2);
}

/* 分页样式增强 */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    padding: 12px 0;
    border-top: 1px solid var(--border-color);
}

.pagination-controls {
    display: flex;
    gap: 4px;
}

.pagination-info {
    font-size: 0.9em;
    color: var(--text-secondary);
}

.pagination button {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s ease;
}

.pagination button:hover:not(:disabled) {
    background: var(--hover-color);
    border-color: var(--primary-color);
}

.pagination button.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 用户管理页面字体缩小 */
[data-page="users"] .table {
    font-size: 0.85em;
}

[data-page="users"] .table th {
    font-size: 0.9em;
    padding: 8px 6px;
}

[data-page="users"] .table td {
    padding: 8px 6px;
    line-height: 1.4;
}

[data-page="users"] .btn {
    font-size: 0.8em;
    padding: 4px 8px;
}

[data-page="users"] .badge {
    font-size: 0.75em;
    padding: 2px 6px;
}

[data-page="users"] .toolbar {
    font-size: 0.9em;
}

[data-page="users"] .form-control {
    font-size: 0.85em;
}

/* 移动端组件优化 */
@media (max-width: 767px) {
    /* 模态框优化 */
    .modal-content {
        max-width: 95vw;
        max-height: 95vh;
        margin: 10px;
    }

    .modal-header {
        padding: 16px;
    }

    .modal-header h3 {
        font-size: 16px;
    }

    .modal-body {
        padding: 16px;
        font-size: 14px;
    }

    .modal-footer {
        padding: 12px 16px 16px;
        flex-wrap: wrap;
    }

    .modal-footer .btn {
        flex: 1;
        min-width: 120px;
    }

    /* Toast提示优化 */
    .toast {
        top: auto;
        bottom: 20px;
        right: 10px;
        left: 10px;
        max-width: none;
        padding: 14px 16px;
        font-size: 14px;
        transform: translateY(100%);
    }

    .toast.show {
        transform: translateY(0);
    }

    /* 标签页优化 */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .tabs::-webkit-scrollbar {
        display: none;
    }

    .tab {
        padding: 10px 16px;
        font-size: 14px;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* 代码块优化 */
    .code-block {
        font-size: 12px;
        padding: 10px;
        overflow-x: auto;
    }

    .code-block pre {
        font-size: 11px;
        padding: 12px;
    }

    .code-block code {
        font-size: 11px;
        padding: 6px 10px;
    }

    /* 帮助内容优化 */
    .help-content {
        padding: 12px;
    }

    .help-section h4 {
        font-size: 1.1em;
    }

    .help-section p {
        font-size: 14px;
    }

    /* 变量网格优化 */
    .variable-grid {
        grid-template-columns: 1fr;
    }

    .variable-item {
        font-size: 13px;
    }

    /* 测试工具优化 */
    .test-tool {
        flex-direction: column;
        align-items: stretch;
    }

    .test-tool .btn {
        width: 100%;
    }

    /* 分页控件优化 */
    .pagination-controls {
        flex-wrap: wrap;
        justify-content: center;
    }

    .pagination-info {
        width: 100%;
        text-align: center;
        margin-bottom: 8px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    /* 模态框小屏幕优化 */
    .modal-content {
        max-width: 100vw;
        max-height: 100vh;
        margin: 0;
        border-radius: 0;
    }

    .modal-header h3 {
        font-size: 15px;
    }

    .modal-body {
        padding: 12px;
        font-size: 13px;
    }

    /* Toast小屏幕优化 */
    .toast {
        bottom: 10px;
        right: 5px;
        left: 5px;
        padding: 12px;
        font-size: 13px;
    }

    /* 标签页小屏幕优化 */
    .tab {
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    /* 增加按钮点击区域 */
    .btn {
        min-height: 44px;
        padding: 12px 20px;
    }

    .btn-sm {
        min-height: 36px;
        padding: 8px 14px;
    }

    /* 增加导航项点击区域 */
    .nav-item {
        min-height: 48px;
    }

    /* 增加表格行高 */
    .table td {
        min-height: 44px;
    }

    /* 增加开关点击区域 */
    .switch {
        width: 52px;
        height: 28px;
    }

    .slider:before {
        height: 22px;
        width: 22px;
    }

    input:checked + .slider:before {
        transform: translateX(24px);
    }
}