/**
 * フロントエンド マークダウンコンバーター スタイル
 */

.markdown-converter-frontend {
    max-width: 100%;
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ヘッダー */
.converter-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    text-align: center;
    border-radius: 8px 8px 0 0;
}

.converter-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

/* メインコンテンツ */
.converter-main {
    padding: 20px;
}

/* フォーマット選択 */
.format-selector {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f0f0f1;
}

.format-label {
    display: block;
    font-weight: 600;
    margin-bottom: 10px;
    color: #2c3e50;
}

.format-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.format-btn {
    padding: 8px 16px;
    border: 2px solid #dcdcde;
    background: #fff;
    color: #50575e;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 13px;
}

.format-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.format-btn.active {
    background: #667eea;
    color: #fff;
    border-color: #667eea;
}

/* コンテンツエリア */
.converter-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.input-section,
.output-section {
    display: flex;
    flex-direction: column;
}

.section-label {
    font-weight: 600;
    margin-bottom: 10px;
    color: #2c3e50;
    font-size: 14px;
}

/* テキストエリア */
.input-textarea,
.output-textarea,
.split-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #dcdcde;
    border-radius: 6px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.3s ease;
}

.input-textarea:focus,
.output-textarea:focus,
.split-textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.output-textarea,
.split-textarea {
    background-color: #f8f9fa;
}

/* 入力情報 */
.input-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: 12px;
    color: #6c757d;
}

.char-count {
    font-weight: 500;
}

.format-info {
    font-style: italic;
}

/* ボタン */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 13px;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

.btn-primary {
    background: #667eea;
    color: #fff;
}

.btn-primary:hover {
    background: #5a6fd8;
    transform: translateY(-1px);
}

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

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

/* コントロール */
.output-controls {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

/* プレビューセクション */
.preview-section {
    margin-top: 20px;
    border: 1px solid #dcdcde;
    border-radius: 6px;
    background: #fff;
    max-height: 300px;
    overflow-y: auto;
}

.preview-section h4 {
    background: #f8f9fa;
    margin: 0;
    padding: 12px 15px;
    border-bottom: 1px solid #dcdcde;
    font-size: 14px;
    font-weight: 600;
}

.preview-content {
    padding: 15px;
    line-height: 1.6;
}

.preview-content h1,
.preview-content h2,
.preview-content h3,
.preview-content h4,
.preview-content h5,
.preview-content h6 {
    margin: 15px 0 8px 0;
    color: #2c3e50;
}

.preview-content p {
    margin: 8px 0;
}

.preview-content code {
    background: #f1f3f4;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: Monaco, Menlo, monospace;
    font-size: 12px;
}

.preview-content pre {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
}

.preview-content blockquote {
    border-left: 4px solid #667eea;
    padding-left: 12px;
    margin: 12px 0;
    color: #6c757d;
}

/* 分割セクション */
.split-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 6px;
    border: 1px solid #e9ecef;
    margin-top: 20px;
}

.split-title {
    margin: 0 0 8px 0;
    font-size: 1.1rem;
    color: #2c3e50;
}

.split-description {
    color: #6c757d;
    margin-bottom: 15px;
    font-size: 14px;
}

.split-controls {
    margin-bottom: 20px;
}

.split-label {
    display: block;
    font-weight: 600;
    margin-bottom: 10px;
    color: #2c3e50;
    font-size: 14px;
}

.split-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.split-btn {
    padding: 8px 16px;
    border: 2px solid #667eea;
    background: #fff;
    color: #667eea;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 13px;
}

.split-btn:hover,
.split-btn.active {
    background: #667eea;
    color: #fff;
    transform: translateY(-1px);
}

.custom-split {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.custom-split-input {
    padding: 8px 12px;
    border: 1px solid #dcdcde;
    border-radius: 6px;
    width: 120px;
    font-size: 13px;
}

.custom-split-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.split-output {
    margin-top: 20px;
}

.split-textarea {
    min-height: 200px;
    margin-bottom: 15px;
}

.split-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* 分割ファイル管理エリア */
.split-bulk-actions {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #e9ecef;
}

.split-bulk-actions h4 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 1.1rem;
}

.bulk-action-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.bulk-check-controls {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

/* 分割ファイルグリッド */
.split-files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.split-file-item {
    border: 1px solid #dcdcde;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
    transition: box-shadow 0.3s ease;
}

.split-file-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.split-file-header {
    background: #f6f7f7;
    padding: 12px 15px;
    border-bottom: 1px solid #dcdcde;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.split-file-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #2c3e50;
}

.split-file-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.split-file-stats {
    font-size: 12px;
    color: #6c757d;
}

.split-file-content {
    padding: 15px;
}

.split-file-textarea {
    width: 100%;
    height: 150px;
    padding: 10px;
    border: 1px solid #dcdcde;
    border-radius: 6px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 12px;
    line-height: 1.4;
    resize: vertical;
    background: #f8f9fa;
}

.split-file-textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.split-file-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    justify-content: center;
}

.split-file-actions .btn {
    padding: 6px 12px;
    font-size: 12px;
    flex: 1;
}

/* 選択状態のスタイル */
.split-file-item.selected {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.split-file-item.selected .split-file-header {
    background: #e8f0fe;
}

/* 統計情報 */
.split-summary {
    background: #e8f4fd;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    border-left: 4px solid #667eea;
}

.split-summary-stats {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.split-summary-stat {
    font-size: 13px;
    color: #2c3e50;
}

.split-summary-stat strong {
    color: #667eea;
}

/* ステータスメッセージ */
.status-message {
    margin-top: 15px;
    padding: 10px 15px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
}

.status-message.success {
    background: #d1e7dd;
    color: #0f5132;
    border: 1px solid #badbcc;
}

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

.status-message.info {
    background: #cff4fc;
    color: #055160;
    border: 1px solid #b6effb;
}

/* テーマバリエーション */

/* ダークテーマ */
.theme-dark {
    background: #2c3e50;
    border-color: #34495e;
    color: #ecf0f1;
}

.theme-dark .converter-header {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
}

.theme-dark .converter-main {
    background: #2c3e50;
}

.theme-dark .section-label,
.theme-dark .format-label,
.theme-dark .split-label,
.theme-dark .split-title {
    color: #ecf0f1;
}

.theme-dark .input-textarea,
.theme-dark .output-textarea,
.theme-dark .split-textarea,
.theme-dark .custom-split-input {
    background: #34495e;
    border-color: #4a5f7a;
    color: #ecf0f1;
}

.theme-dark .input-textarea:focus,
.theme-dark .output-textarea:focus,
.theme-dark .split-textarea:focus,
.theme-dark .custom-split-input:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.theme-dark .format-btn,
.theme-dark .split-btn {
    background: #34495e;
    border-color: #4a5f7a;
    color: #ecf0f1;
}

.theme-dark .format-btn:hover,
.theme-dark .split-btn:hover {
    border-color: #3498db;
    color: #3498db;
}

.theme-dark .format-btn.active,
.theme-dark .split-btn.active {
    background: #3498db;
    color: #fff;
    border-color: #3498db;
}

.theme-dark .split-section {
    background: #34495e;
    border-color: #4a5f7a;
}

.theme-dark .preview-section {
    background: #34495e;
    border-color: #4a5f7a;
}

.theme-dark .preview-section h4 {
    background: #2c3e50;
    border-color: #4a5f7a;
    color: #ecf0f1;
}

.theme-dark .preview-content {
    color: #ecf0f1;
}

.theme-dark .preview-content h1,
.theme-dark .preview-content h2,
.theme-dark .preview-content h3,
.theme-dark .preview-content h4,
.theme-dark .preview-content h5,
.theme-dark .preview-content h6 {
    color: #ecf0f1;
}

.theme-dark .preview-content code {
    background: #2c3e50;
    color: #e74c3c;
}

.theme-dark .preview-content pre {
    background: #2c3e50;
}

.theme-dark .input-info,
.theme-dark .split-description,
.theme-dark .split-info {
    color: #bdc3c7;
}

/* ミニマルテーマ */
.theme-minimal {
    border: none;
    box-shadow: none;
    background: transparent;
}

.theme-minimal .converter-header {
    background: none;
    color: #2c3e50;
    border-bottom: 2px solid #ecf0f1;
    padding: 15px 0;
}

.theme-minimal .converter-main {
    padding: 15px 0;
}

.theme-minimal .input-textarea,
.theme-minimal .output-textarea,
.theme-minimal .split-textarea {
    border: 1px solid #bdc3c7;
    border-radius: 4px;
}

.theme-minimal .format-btn,
.theme-minimal .split-btn {
    border: 1px solid #bdc3c7;
    border-radius: 4px;
}

.theme-minimal .format-btn.active,
.theme-minimal .split-btn.active {
    background: #2c3e50;
    color: #fff;
    border-color: #2c3e50;
}

.theme-minimal .btn-primary {
    background: #2c3e50;
}

.theme-minimal .btn-primary:hover {
    background: #34495e;
}

.theme-minimal .split-section {
    background: #f8f9fa;
    border: 1px solid #ecf0f1;
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    .markdown-converter-frontend {
        margin: 10px 0;
    }
    
    .converter-main {
        padding: 15px;
    }
    
    .converter-content {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .format-buttons,
    .split-buttons,
    .output-controls,
    .split-actions {
        justify-content: center;
    }
    
    .format-selector {
        text-align: center;
    }
    
    .format-label,
    .split-label {
        text-align: center;
    }
    
    .custom-split {
        justify-content: center;
        flex-direction: column;
        gap: 10px;
    }
    
    .split-section {
        padding: 15px;
    }
    
    .input-info {
        flex-direction: column;
        gap: 5px;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .converter-header {
        padding: 15px;
    }
    
    .converter-title {
        font-size: 1.2rem;
    }
    
    .converter-main {
        padding: 10px;
    }
    
    .format-buttons,
    .split-buttons,
    .output-controls,
    .split-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .format-btn,
    .split-btn,
    .btn {
        width: 100%;
        justify-content: center;
        margin-bottom: 5px;
    }
    
    .custom-split-input {
        width: 100%;
    }
}

/* ローディング状態 */
.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* アニメーション */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(-10px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.slide-down {
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        max-height: 500px;
        transform: translateY(0);
    }
}

/* アクセシビリティ */
.btn:focus,
.format-btn:focus,
.split-btn:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.input-textarea:focus,
.output-textarea:focus,
.split-textarea:focus,
.custom-split-input:focus {
    outline: 2px solid #667eea;
    outline-offset: 1px;
}

/* ダークモード対応 */
@media (prefers-color-scheme: dark) {
    .markdown-converter-frontend:not(.theme-dark):not(.theme-minimal) {
        background: #1e1e1e;
        border-color: #333;
        color: #e0e0e0;
    }
    
    .markdown-converter-frontend:not(.theme-dark):not(.theme-minimal) .input-textarea,
    .markdown-converter-frontend:not(.theme-dark):not(.theme-minimal) .output-textarea,
    .markdown-converter-frontend:not(.theme-dark):not(.theme-minimal) .split-textarea {
        background: #2d2d2d;
        border-color: #444;
        color: #e0e0e0;
    }
    
    .markdown-converter-frontend:not(.theme-dark):not(.theme-minimal) .section-label,
    .markdown-converter-frontend:not(.theme-dark):not(.theme-minimal) .format-label,
    .markdown-converter-frontend:not(.theme-dark):not(.theme-minimal) .split-label {
        color: #e0e0e0;
    }
}

/* 印刷対応 */
@media print {
    .markdown-converter-frontend {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .converter-header {
        background: none !important;
        color: #000 !important;
    }
    
    .btn,
    .format-btn,
    .split-btn,
    .output-controls,
    .split-actions {
        display: none !important;
    }
    
    .input-textarea,
    .output-textarea,
    .split-textarea {
        border: 1px solid #000;
        background: #fff !important;
        color: #000 !important;
    }
}