/* ========================================
   JavaScript格式化/压缩工具 - 专用样式
   依赖: tools-common.css (提供 info-card、广告位、工具头部样式)
   ======================================== */

/* 工具功能区布局 */
.js-tool-input-section,
.js-tool-output-section {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* 分栏布局（桌面端） */
@media (min-width: 1100px) {
    .tool-page .tool-content.full-width {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 24px;
    }
}

/* 章节标题 */
.js-tool-section-header h2 {
    margin: 0 0 8px;
    font-size: 1.4rem;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 10px;
}

.js-tool-section-header h2 i {
    font-size: 1.3rem;
    color: #0ea5e9;
}

.js-tool-subtitle {
    margin: 0;
    color: #64748b;
    line-height: 1.6;
    font-size: 0.95rem;
}

/* 输入/输出文本框 */
.js-tool-textarea,
.js-tool-output {
    width: 100%;
    border: 1px solid rgba(148, 163, 184, 0.4);
    border-radius: 12px;
    padding: 16px;
    font-family: "Fira Code", "JetBrains Mono", Consolas, Monaco, "Courier New", monospace;
    font-size: 0.92rem;
    line-height: 1.55;
    min-height: 280px;
    color: #0f172a;
    background: #f8fafc;
    resize: vertical;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.js-tool-textarea:focus {
    border-color: #38bdf8;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
    outline: none;
    background: #fff;
}

.js-tool-output {
    background: #0f172a;
    color: #e2e8f0;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

/* 拖拽区域 */
.js-tool-drop {
    border: 2px dashed rgba(148, 163, 184, 0.4);
    border-radius: 14px;
    padding: 12px;
    background: rgba(248, 250, 252, 0.5);
    transition: border-color 0.25s ease, background 0.25s ease;
}

.js-tool-drop.dragover {
    border-color: #0ea5e9;
    background: rgba(224, 242, 254, 0.4);
}

/* 元数据显示 */
.js-tool-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
    align-items: center;
    font-size: 0.88rem;
    color: #64748b;
}

.js-tool-meta span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* 操作按钮组 */
.js-tool-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.js-tool-actions .btn {
    border-radius: 10px;
    font-weight: 600;
    padding: 10px 16px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.92rem;
}

.js-tool-actions .btn i {
    font-size: 1rem;
}

.js-tool-actions .btn-primary {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    color: #fff;
    border: none;
}

.js-tool-actions .btn-primary:hover {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

.js-tool-actions .btn-secondary {
    background: #e2e8f0;
    color: #0f172a;
    border: none;
}

.js-tool-actions .btn-secondary:hover {
    background: #cbd5e1;
    transform: translateY(-1px);
}

.js-tool-actions .btn-ghost {
    background: transparent;
    border: 1px solid rgba(148, 163, 184, 0.5);
    color: #475569;
}

.js-tool-actions .btn-ghost:hover {
    border-color: #0284c7;
    color: #0284c7;
    background: rgba(14, 165, 233, 0.05);
}

/* 配置选项区域 */
.js-tool-options {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.js-tool-option-group {
    background: rgba(241, 245, 249, 0.7);
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.js-tool-option-group strong {
    color: #0f172a;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.js-tool-option-group strong i {
    color: #0ea5e9;
}

.js-tool-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    color: #475569;
}

.js-tool-option-group select,
.js-tool-option-group input[type="number"] {
    border: 1px solid rgba(148, 163, 184, 0.4);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 0.88rem;
    color: #0f172a;
    background: #fff;
    flex: 1;
}

.js-tool-option-group input[type="number"] {
    min-width: 0;
}

/* 示例代码按钮 */
.js-tool-sample-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.js-tool-sample-button {
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 10px;
    padding: 12px 14px;
    background: #fff;
    color: #0f172a;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    font-weight: 500;
}

.js-tool-sample-button:hover {
    border-color: #0284c7;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.2);
}

.js-tool-sample-button i {
    color: #0ea5e9;
    font-size: 1.1rem;
}

/* 状态区域 */
.js-tool-status-area {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    font-size: 0.88rem;
    color: #64748b;
}

.js-tool-status-area #jsStatus {
    color: #475569;
}

/* 加载指示器 */
.js-tool-loading {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #0ea5e9;
    font-size: 0.9rem;
    font-weight: 600;
}

.js-tool-loading::after {
    content: "";
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(14, 165, 233, 0.2);
    border-top-color: #0ea5e9;
    animation: js-tool-spin 0.8s linear infinite;
}

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

/* 输出区域头部 */
.js-tool-output-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.js-tool-output-header h3 {
    margin: 0;
    font-size: 1.3rem;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 10px;
}

.js-tool-output-header h3 i {
    color: #0ea5e9;
}

/* 标签页切换 */
.js-tool-tabs {
    display: inline-flex;
    border-radius: 10px;
    background: rgba(148, 163, 184, 0.12);
    padding: 3px;
    gap: 3px;
}

.js-tool-tab {
    border: none;
    background: transparent;
    color: #64748b;
    padding: 8px 14px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.js-tool-tab.active {
    background: #0ea5e9;
    color: #fff;
}

.js-tool-tab:hover:not(.active) {
    color: #0f172a;
    background: rgba(148, 163, 184, 0.15);
}

/* 分析面板 */
.js-tool-insights {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    margin-bottom: 20px;
}

.js-tool-insight-card {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: #f8fafc;
    border-radius: 14px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.js-tool-insight-card h4 {
    margin: 0;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #f8fafc;
}

.js-tool-insight-card h4 i {
    color: #38bdf8;
}

.js-tool-insight-card ul {
    margin: 0;
    padding-left: 20px;
    line-height: 1.7;
    color: #e2e8f0;
}

.js-tool-insight-card li {
    margin-bottom: 6px;
}

/* 操作历史 */
.js-tool-history {
    background: rgba(241, 245, 249, 0.6);
    border: 1px dashed rgba(148, 163, 184, 0.5);
    border-radius: 14px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.js-tool-history h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 8px;
}

.js-tool-history h3 i {
    color: #0ea5e9;
}

.js-tool-history ul {
    margin: 0;
    padding-left: 20px;
    color: #475569;
    line-height: 1.6;
}

.js-tool-history li {
    margin-bottom: 8px;
}

.js-tool-history li strong {
    color: #0f172a;
}

.js-tool-empty {
    text-align: center;
    border: 1px dashed rgba(148, 163, 184, 0.5);
    border-radius: 12px;
    padding: 28px 18px;
    color: #64748b;
    background: rgba(248, 250, 252, 0.6);
    font-size: 0.9rem;
}

/* Toast 提示 */
.js-tool-toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: rgba(15, 23, 42, 0.95);
    color: #f8fafc;
    padding: 13px 18px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.3);
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 9999;
    max-width: 400px;
}

.js-tool-toast.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.js-tool-toast.success {
    border-left: 3px solid #22c55e;
}

.js-tool-toast.error {
    border-left: 3px solid #ef4444;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .js-tool-section-header h2 {
        font-size: 1.2rem;
    }

    .js-tool-textarea,
    .js-tool-output {
        min-height: 200px;
        font-size: 0.88rem;
    }

    .js-tool-actions {
        flex-direction: column;
    }

    .js-tool-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .js-tool-options {
        grid-template-columns: 1fr;
    }

    .js-tool-sample-grid {
        grid-template-columns: 1fr;
    }

    .js-tool-toast {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }

    .js-tool-insights {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .js-tool-output-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .js-tool-tabs {
        width: 100%;
    }

    .js-tool-tab {
        flex: 1;
        text-align: center;
    }
}
