/**
 * HTML/CSS Live Editor - Main Styles
 * Version: 2.0.2
 */

/* 基本リセット */
.html-css-live-editor {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    margin: 20px 0;
    position: relative;
}

.html-css-live-editor * {
    box-sizing: border-box;
}

/* エディタヘッダー */
.editor-header {
    background: #2c3e50;
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    height: 80px;
}

.editor-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
}

.editor-controls {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

/* ボタンスタイル */
.editor-controls button,
.file-input {
    background: #3498db;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s;
    text-decoration: none;
    display: inline-block;
}

.editor-controls button:hover,
.file-input:hover {
    background: #2980b9;
}

.file-input {
    position: relative;
    overflow: hidden;
}

.file-input input[type=file] {
    position: absolute;
    left: -9999px;
}

.btn-save {
    background: #27ae60 !important;
}

.btn-save:hover {
    background: #219a52 !important;
}

.btn-download {
    background: #e67e22 !important;
}

.btn-download:hover {
    background: #d35400 !important;
}

/* メインレイアウト */
.editor-main {
    display: flex;
    height: calc(600px - 80px);
    min-height: 400px;
}

/* プレビューセクション */
.preview-section {
    flex: 0 0 60%;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    background: white;
    position: relative;
}

/* エディタセクション */
.editor-section {
    flex: 0 0 40%;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
    position: relative;
}

/* プレビューヘッダー */
.preview-header {
    background: #34495e;
    color: white;
    padding: 0.5rem 1rem;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.preview-info {
    font-size: 0.8rem;
    opacity: 0.8;
}

/* プレビューコンテナ */
.preview-container {
    flex: 1;
    position: relative;
    overflow: auto;
    background: #fff;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
}

.preview-wrapper {
    width: 100%;
    height: 100%;
    min-width: 400px;
    min-height: 300px;
}

.preview-frame {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
}

/* コントロールパネル */
.controls-panel {
    flex: 0 0 200px;
    min-height: 150px;
    background: white;
    border-bottom: 1px solid #ddd;
    padding: 1rem;
    overflow-y: auto;
    position: relative;
}

.control-group {
    margin-bottom: 1rem;
}

.control-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #2c3e50;
    font-size: 0.9rem;
}

.selected-element-info {
    background: #ecf0f1;
    padding: 0.5rem;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.8rem;
    color: #2c3e50;
    border: 1px solid #bdc3c7;
    margin-bottom: 0.5rem;
    word-break: break-all;
}

.css-jump-btn {
    background: #e67e22;
    color: white;
    border: none;
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.3s;
    margin-right: 0.25rem;
}

.css-jump-btn:hover {
    background: #d35400;
}

.element-navigation {
    margin-top: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

/* エディタコンテンツラッパー */
.editor-content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 200px;
}

/* エディタタブ */
.editor-tabs {
    display: flex;
    background: #ecf0f1;
    border-bottom: 1px solid #ddd;
    flex-shrink: 0;
}

.tab-btn {
    background: none;
    border: none;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: #7f8c8d;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
}

.tab-btn.active {
    color: #2c3e50;
    background: white;
    border-bottom-color: #3498db;
}

.tab-btn:hover:not(.active) {
    background: #e8f4fd;
    color: #2c3e50;
}

/* エディタコンテンツ */
.editor-content {
    flex: 1;
    position: relative;
    min-height: 0;
}

.editor-tab {
    display: none;
    height: 100%;
}

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

.code-editor {
    width: 100%;
    height: 100%;
    border: none;
    font-family: 'Courier New', 'Monaco', monospace;
    font-size: 13px;
    padding: 1rem;
    background: #2d3748;
    color: #e2e8f0;
    resize: none;
    outline: none;
    line-height: 1.5;
    transition: background-color 0.3s ease;
}

.code-editor::placeholder {
    color: #a0aec0;
}

.code-editor.highlight {
    background: #f39c12 !important;
    color: #2c3e50 !important;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ローディング表示 */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* メッセージ表示 */
.message-container {
    position: fixed;
    top: 100px;
    right: 20px;
    z-index: 10000;
    max-width: 300px;
}

.message {
    padding: 0.75rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

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

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

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .editor-main {
        flex-direction: column;
    }
    
    .preview-section,
    .editor-section {
        flex: 1 1 auto;
        min-width: auto;
    }
    
    .controls-panel {
        flex: 0 0 150px;
    }
    
    .editor-controls {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .editor-controls button {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
    
    .editor-header {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
        height: auto;
        min-height: 80px;
    }
}