/* 代碼美化器專用樣式 */

/* 語言選擇區 */
.language-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--light-gray);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.language-section h3 {
    margin: 0 0 1rem 0;
    color: var(--text-color);
    font-size: 1.1rem;
    font-weight: 600;
}

.language-tabs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
}

.language-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--card-bg, white);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-color);
}

.language-tab:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.language-tab.active {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    box-shadow: 0 4px 12px rgba(247, 147, 26, 0.3);
}

.tab-icon {
    font-size: 1.5rem;
}

.tab-text {
    font-size: 0.9rem;
    font-weight: 600;
}

/* 格式化選項區 */
.options-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--card-bg, white);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.options-section h3 {
    margin: 0 0 1.5rem 0;
    color: var(--text-color);
    font-size: 1.1rem;
    font-weight: 600;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.5rem;
}

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

.option-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.option-group label {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.9rem;
}

.option-select {
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    background: var(--card-bg, white);
    color: var(--text-color);
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.option-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(247, 147, 26, 0.1);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: normal !important;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

/* 編輯區域 */
.editor-section {
    margin-bottom: 2rem;
}

.editor-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.editor-panel {
    display: flex;
    flex-direction: column;
    background: var(--card-bg, white);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--light-gray);
    border-bottom: 1px solid var(--border-color);
}

.editor-header h4 {
    margin: 0;
    color: var(--text-color);
    font-size: 1rem;
    font-weight: 600;
}

.editor-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-small {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    border-radius: 6px;
    background: var(--card-bg, white);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.btn-small:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.code-editor {
    flex: 1;
    min-height: 400px;
    padding: 1.5rem;
    border: none;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    resize: none;
    background: var(--card-bg, white);
    color: var(--text-color);
    overflow: auto;
}

.code-editor:focus {
    outline: none;
    background: var(--light-gray);
}

.output-code {
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
    background: var(--light-gray);
    color: var(--text-color);
}

.editor-info {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background: var(--light-gray);
    border-top: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--text-color);
}

.char-count,
.line-count,
.compression-ratio {
    font-weight: 500;
}

.char-count span,
.line-count span,
.compression-ratio span {
    font-weight: 600;
    color: var(--primary-color);
}

/* 主要操作按鈕 */
.main-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 1.75rem;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    box-shadow: 0 4px 12px rgba(247, 147, 26, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(247, 147, 26, 0.4);
}

.btn:not(.btn-primary) {
    background: var(--card-bg, white);
    color: var(--text-color);
    border: 2px solid var(--border-color);
}

.btn:not(.btn-primary):hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn-icon {
    font-size: 1.1rem;
}

/* 範例區域 */
.examples-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--light-gray);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.examples-section h3 {
    margin: 0 0 1rem 0;
    color: var(--text-color);
    font-size: 1.1rem;
    font-weight: 600;
}

.examples-grid {
    position: relative;
}

.example-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
}

.example-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--card-bg, white);
    color: var(--text-color);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.example-btn:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.example-icon {
    font-size: 1.5rem;
}

.example-name {
    font-weight: 600;
    font-size: 0.9rem;
    text-align: center;
}

/* 教學內容樣式 */
.options-explanation {
    display: grid;
    gap: 1.5rem;
}

.option-item h4 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.option-item p {
    color: var(--text-color);
    line-height: 1.6;
}

.language-guides {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.lang-guide {
    padding: 1.5rem;
    background: var(--light-gray);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.lang-guide h4 {
    color: var(--secondary-color);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.lang-guide ul {
    padding-left: 1.5rem;
    margin: 0;
}

.lang-guide li {
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

/* 響應式設計 */
@media (max-width: 968px) {
    .editor-container {
        grid-template-columns: 1fr;
    }

    .language-tabs {
        grid-template-columns: repeat(3, 1fr);
    }

    .options-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .main-actions {
        flex-direction: column;
    }

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

    .language-guides {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .language-tabs {
        grid-template-columns: repeat(2, 1fr);
    }

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

    .editor-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .editor-actions {
        width: 100%;
        justify-content: space-between;
    }

    .btn-small {
        flex: 1;
        text-align: center;
    }

    .code-editor {
        min-height: 300px;
        font-size: 0.85rem;
        padding: 1rem;
    }

    .editor-info {
        flex-direction: column;
        gap: 0.5rem;
    }

    .example-group {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .language-section,
    .options-section,
    .examples-section {
        padding: 1rem;
    }

    .language-tabs {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .language-tab {
        flex-direction: row;
        justify-content: center;
        padding: 0.75rem;
    }

    .tab-icon {
        font-size: 1.2rem;
    }

    .code-editor {
        min-height: 250px;
        font-size: 0.8rem;
        padding: 0.75rem;
    }

    .editor-actions {
        flex-direction: column;
        gap: 0.5rem;
    }

    .btn-small {
        width: 100%;
    }
}

/* 語法高亮樣式 */
.syntax-keyword {
    color: #d73a49;
    font-weight: 600;
}

.syntax-string {
    color: #032f62;
}

.syntax-number {
    color: #005cc5;
}

.syntax-comment {
    color: #6a737d;
    font-style: italic;
}

.syntax-function {
    color: #6f42c1;
}

.syntax-tag {
    color: #22863a;
}

.syntax-attribute {
    color: #005cc5;
}

.syntax-property {
    color: #e36209;
}

/* 動畫效果 */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.processing {
    animation: pulse 1.5s ease-in-out infinite;
}

/* 成功/錯誤提示 */
.message {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-weight: 500;
}

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

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

.message-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}