/**
 * Console2 Edit CSS
 * 記事編集画面専用のスタイル
 */

/* ========================================
   追加CSS変数（edit用）
   ======================================== */
:root {
    /* プライマリカラー（console2_commonとの互換性） */
    --primary-color: var(--accent-primary);
    --primary-hover: var(--accent-dark);
    --danger-color: var(--warning-primary);
    --danger-hover: var(--warning-dark);

    /* 角丸 */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    /* テキストカラー補足 */
    --text-muted: var(--text-light);
}

/* ========================================
   フォームカード
   ======================================== */
.edit-form-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    padding: 0;
    overflow: hidden;
}

.edit-form-section {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-light);
}

.edit-form-section:last-child {
    border-bottom: none;
}

.edit-form-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.edit-form-section-title i {
    font-size: 1rem;
    color: var(--accent-primary);
}

/* ========================================
   ステータス行
   ======================================== */
.status-row {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ========================================
   統合入力エリア（日時+タイトル）
   ======================================== */
.unified-input-area {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 1rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.unified-input-area:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(81, 187, 155, 0.1);
}

.unified-input-header {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-light);
}

.unified-date-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    padding: 0.25rem 0;
    font-family: inherit;
    outline: none;
}

.unified-title-input {
    width: 100%;
    border: none;
    background: transparent;
    font-size: 1.375rem;
    font-weight: 600;
    color: var(--text-primary);
    padding: 0.875rem 1rem;
    font-family: inherit;
    outline: none;
}

.status-item label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.view-stats {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-left: auto;
    font-size: 0.875rem;
    color: var(--text-light);
}

.view-stats span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* ========================================
   入力スタイル
   ======================================== */
.edit-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: inherit;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.edit-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(81, 187, 155, 0.1);
}

.edit-input-title {
    font-size: 1.5rem;
    font-weight: 600;
    border: none;
    border-bottom: 2px solid var(--border-light);
    border-radius: 0;
    padding: 0.75rem 0;
}

.edit-input-title:focus {
    border-color: var(--accent-primary);
    box-shadow: none;
}

.edit-textarea {
    min-height: 300px;
    height: 500px;
    resize: vertical;
    font-family: 'Courier New', Consolas, monospace;
    font-size: 0.9375rem;
    line-height: 1.7;
}

.edit-select {
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-family: inherit;
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%236b7280' d='M4.427 6.427l3.396 3.396a.25.25 0 00.354 0l3.396-3.396A.25.25 0 0011.396 6H4.604a.25.25 0 00-.177.427z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    transition: all var(--transition-fast);
}

.edit-select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* ========================================
   日付入力行
   ======================================== */
.date-input-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.date-input-row .edit-input {
    flex: 1;
}

.date-reload-btn {
    padding: 0.375rem;
    border: none;
    background: transparent;
    color: var(--text-light);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.date-reload-btn:hover {
    color: var(--accent-primary);
    background: rgba(81, 187, 155, 0.1);
}

.unified-input-header .date-reload-btn {
    margin-left: 0.5rem;
}

/* ========================================
   画像アップロードエリア
   ======================================== */
.image-upload-area {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-base);
    background: var(--bg-primary);
}

.drop-zone:hover {
    border-color: var(--accent-primary);
    background: rgba(81, 187, 155, 0.02);
}

.drop-zone.dragover {
    border-color: var(--accent-primary);
    background: rgba(81, 187, 155, 0.05);
}

/* 画像ドラッグ時の視覚的フィードバック */
.preview_item.dragover {
    outline: 3px solid var(--accent-primary);
    outline-offset: -3px;
    box-shadow: inset 0 0 0 3px rgba(81, 187, 155, 0.3);
    position: relative;
}

.preview_item.dragover::before {
    content: 'ここに挿入';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(81, 187, 155, 0.85);
    z-index: 10;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
}

/* ドロップエリア2（追加ボタン）のドラッグオーバー */
#drop_area2.dragover {
    border-color: var(--accent-primary);
    background: rgba(81, 187, 155, 0.1);
}

#drop_area2.dragover span {
    color: var(--accent-primary);
}

.drop-zone-icon {
    font-size: 2.5rem;
    color: var(--text-light);
    margin-bottom: 1rem;
}

.drop-zone-text {
    font-size: 0.9375rem;
    color: var(--text-secondary);
}

.drop-zone-text strong {
    color: var(--accent-primary);
}

/* ========================================
   プレビューリスト
   ======================================== */
#preview_list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
    list-style: none;
    padding: 0;
    margin: 0;
}

#preview_list li {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-secondary);
    cursor: grab;
}

#preview_list li:active {
    cursor: grabbing;
}

#preview_list li img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#preview_list li.ghost {
    opacity: 0.3;
}

#drop_area2_root {
    aspect-ratio: 1;
}

#drop_area2 {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    padding: 0;
}

#drop_area2:hover {
    border-color: var(--accent-primary);
}

#drop_area2 span {
    font-size: 0.75rem;
    color: var(--text-light);
    text-align: center;
    padding: 0.5rem;
}

.thumb-setting {
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.thumb-setting label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ========================================
   タグエリア
   ======================================== */
.tag-input-area {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tag-cloud-title {
    font-size: 0.75rem;
    color: var(--text-light);
}

.console-tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
    width: 100%;
}

.p-tag-cloud .p-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    margin: 0.1rem 0.25rem;
}

.p-tag-cloud .p-tag:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

/* ========================================
   オプショングリッド
   ======================================== */
.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 0.75rem;
}

.option-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.option-item input[type="checkbox"] {
    width: 1.125rem;
    height: 1.125rem;
    accent-color: var(--accent-primary);
}

.option-item label {
    font-size: 0.875rem;
    color: var(--text-primary);
    cursor: pointer;
    text-wrap: nowrap;
}

.pin-priority {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-light);
    margin-left: 0.5rem;
    text-wrap: nowrap;
}

.pin-priority input {
    width: 3rem;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    text-align: center;
}

/* ========================================
   URLエリア
   ======================================== */
.url-input-area {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.url-hint {
    font-size: 0.75rem;
    color: var(--text-light);
}

/* ========================================
   コマンドパレット
   ======================================== */
.command-palette-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-light);
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.command-palette-trigger:hover {
    color: var(--accent-primary);
    background: var(--bg-secondary);
}

.command_palette {
    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: 2000;
    backdrop-filter: blur(4px);
}

.command_palette_inner {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    max-width: 600px;
    width: 90%;
    max-height: 70vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.command_palette_inner ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.command_palette_inner li {
    font-family: 'Courier New', Consolas, monospace;
    font-size: 0.8125rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.command_palette_inner li:hover {
    background: var(--accent-primary);
    color: white;
}

/* ========================================
   送信エリア
   ======================================== */
.submit-area {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.5rem 2rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-light);
}

.submit-btn {
    padding: 0.875rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: inherit;
}

.submit-btn-primary {
    background: var(--accent-primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.submit-btn-primary:hover {
    background: var(--accent-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.submit-btn-danger {
    background: transparent;
    color: var(--warning-primary);
    border: 1px solid var(--warning-primary);
}

.submit-btn-danger:hover {
    background: var(--warning-primary);
    color: white;
}

/* ========================================
   シンタックスハイライター
   ======================================== */
.syntax-editor-container {
    position: relative;
    width: 100%;
    margin: 0;
    padding: 0;
}

.syntax-wrap-toggle {
    position: absolute;
    bottom: -32px;
    right: 0px;
    z-index: 2;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary, #f0f0f0);
    border: 1px solid var(--border-color, #ccc);
    border-radius: 4px;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.15s;
    font-size: 14px;
    color: var(--text-muted, #888);
    line-height: 1;
    padding: 0;
}

.syntax-wrap-toggle:hover {
    opacity: 1;
}

.syntax-wrap-toggle.wrap-on {
    opacity: 0.85;
    color: var(--accent-primary, #0d6efd);
    border-color: var(--accent-primary, #0d6efd);
}

.syntax-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-sizing: border-box;
    text-align: left;
}

.syntax-highlights {
    margin: 0;
    padding: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--text-primary);
    font-family: 'Courier New', Consolas, monospace;
    font-size: 0.9375rem;
    line-height: 1.7;
}

textarea[data-syntax-editor] {
    position: relative;
    z-index: 1;
    background-color: transparent !important;
    color: transparent !important;
    caret-color: var(--text-primary);
    display: block;
}

.syntax-tag {
    color: #d63384;
}

.syntax-var {
    color: #0d6efd;
}

/* テキストエリアへのファイルドラッグオーバー */
.textarea-dragover {
    outline: 3px solid var(--accent-primary) !important;
    outline-offset: -3px;
    background-color: rgba(81, 187, 155, 0.08) !important;
}

.syntax-editor-container:has(.textarea-dragover) .syntax-backdrop {
    background-color: rgba(81, 187, 155, 0.08);
}

/* ========================================
   画像編集オーバーレイ
   ======================================== */
.image_edit_overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    backdrop-filter: blur(8px);
}

.image_edit {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 90vw;
    max-height: 90vh;
    overflow: auto;
    box-shadow: var(--shadow-lg);
}

.image_edit_title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.slider_container {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.75rem 1rem;
    align-items: center;
}

.slider_container_col1 {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.slider_container_col3 {
    font-size: 0.875rem;
    color: var(--text-light);
    width: 2.5rem;
    text-align: right;
}

/* ========================================
   カスタムスライダー（画像編集用）
   ======================================== */
.gradient_slider {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    border-radius: 4px;
    outline: none;
    cursor: pointer;
}

/* 共通のつまみスタイル (WebKit) */
.gradient_slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffffff;
    border: 2px solid rgba(0, 0, 0, 0.2);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    cursor: grab;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.gradient_slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.gradient_slider::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(1.05);
}

/* 共通のつまみスタイル (Firefox) */
.gradient_slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffffff;
    border: 2px solid rgba(0, 0, 0, 0.2);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    cursor: grab;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.gradient_slider::-moz-range-thumb:hover {
    transform: scale(1.1);
}

/* 色温度スライダー: 青(寒色) → 黄色/オレンジ(暖色) */
#temperatureInput {
    background: linear-gradient(to right,
            #3b82f6 0%,
            #60a5fa 20%,
            #e5e7eb 50%,
            #fbbf24 80%,
            #f59e0b 100%);
}

#temperatureInput::-webkit-slider-thumb {
    border-color: rgba(59, 130, 246, 0.4);
}

/* 色かぶり補正スライダー: 緑 → マゼンタ */
#tintInput {
    background: linear-gradient(to right,
            #ec4899 0%,
            #f472b6 20%,
            #e5e7eb 50%,
            #4ade80 80%,
            #22c55e 100%);
}

#tintInput::-webkit-slider-thumb {
    border-color: rgba(34, 197, 94, 0.4);
}

/* 明るさ補正スライダー: 暗い → 明るい */
#brightnessInput {
    background: linear-gradient(to right,
            #1f2937 0%,
            #4b5563 25%,
            #9ca3af 50%,
            #e5e7eb 75%,
            #fef9f9 100%);
}

#brightnessInput::-webkit-slider-thumb {
    border-color: rgba(107, 114, 128, 0.4);
}

/* Firefox用トラックスタイル */
.gradient_slider::-moz-range-track {
    height: 8px;
    border-radius: 4px;
}

#temperatureInput::-moz-range-track {
    background: linear-gradient(to right,
            #3b82f6 0%, #60a5fa 20%, #e5e7eb 50%, #fbbf24 80%, #f59e0b 100%);
}

#tintInput::-moz-range-track {
    background: linear-gradient(to right,
            #22c55e 0%, #4ade80 20%, #e5e7eb 50%, #f472b6 80%, #ec4899 100%);
}

#brightnessInput::-moz-range-track {
    background: linear-gradient(to right,
            #1f2937 0%, #4b5563 25%, #9ca3af 50%, #e5e7eb 75%, #fef9c3 100%);
}

/* 画像編集ボタンエリア */
.image_edit_buttons {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.image_edit_buttons .btn {
    min-width: 100px;
}

#canvas {
    max-width: 100%;
    border-radius: var(--radius-md);
    margin: 1rem 0;
}

/* ========================================
   アラート
   ======================================== */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-warning {
    background: rgba(204, 87, 89, 0.1);
    border: 1px solid rgba(204, 87, 89, 0.3);
    color: var(--warning-primary);
}

.alert-warning a {
    color: var(--warning-primary);
    text-decoration: underline;
}

/* ========================================
   モバイル送信フッター
   ======================================== */
.sp_fix_footer {
    display: none;
}

/* ========================================
   ユーティリティ
   ======================================== */
.hide {
    display: none !important;
}

/* ========================================
   レスポンシブ
   ======================================== */
@media (max-width: 768px) {
    #preview_list {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .edit-form-section {
        padding: 1rem 1.25rem;
    }

    .status-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .view-stats {
        margin-left: 0;
    }

    .unified-title-input {
        font-size: 1.125rem;
        padding: 0.75rem 1rem;
    }

    .unified-input-header {
        padding: 0.375rem 0.75rem;
    }

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

    .submit-area {
        padding: 1rem 1.25rem;
        flex-direction: column;
    }

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

    .sp_fix_footer {
        display: block;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 1rem;
        background: var(--bg-primary);
        border-top: 1px solid var(--border-light);
        z-index: 100;
    }

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

    .command_palette_inner ul {
        grid-template-columns: 1fr;
    }
}