/* --- ダイアログ・モーダルスタイル --- */
.custom-dialog {
    border: 1px solid var(--border-secondary);
    border-radius: 8px;
    padding: 25px;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    box-shadow: 0 5px 20px var(--shadow-secondary);
    min-width: 280px;
    max-width: 500px;
    width: fit-content;
    box-sizing: border-box;
    margin-left: auto;
    margin-right: auto;
    transition:
        background-color 0.3s ease,
        color 0.3s ease,
        border-color 0.3s ease;
    position: relative;
    z-index: 100;
}

.custom-dialog::backdrop {
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
    transition: background-color 0.3s ease;
    z-index: 99;
}

body.dark-mode .custom-dialog::backdrop {
    background-color: rgba(30, 30, 30, 0.7);
}

body.pastel-pink-mode .custom-dialog::backdrop,
body.pastel-blue-mode .custom-dialog::backdrop,
body.pastel-yellow-mode .custom-dialog::backdrop,
body.pastel-purple-mode .custom-dialog::backdrop,
body.pastel-rainbow-mode .custom-dialog::backdrop {
    background-color: rgba(var(--overlay-base-rgb), 0.4);
}

.custom-dialog[open] {
    animation: dialog-fade-in 0.3s ease forwards;
}

/* ── アニメーション ── */
@keyframes dialog-fade-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.custom-dialog .dialog-message {
    margin: 0 0 20px 0;
    font-size: 15px;
    line-height: 1.6;
    display: block;
    text-align: left;
}

.custom-dialog .dialog-input {
    width: 100%;
    padding: 8px 10px;
    margin-bottom: 20px;
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    font-size: 14px;
    background-color: var(--bg-input);
    color: var(--text-primary);
}

.custom-dialog .dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 15px;
}

.custom-dialog button {
    padding: 8px 18px;
    font-weight: 500;
    min-width: 80px;
}

.custom-dialog .dialog-ok-btn {
    background-color: var(--bg-button);
    color: var(--text-light);
}

body.pastel-yellow-mode .custom-dialog .dialog-ok-btn,
body.pastel-rainbow-mode .custom-dialog .dialog-ok-btn {
    color: var(--text-light);
}

.custom-dialog .dialog-ok-btn:hover:not(:disabled) {
    background-color: var(--bg-button-hover);
}

.custom-dialog .dialog-cancel-btn {
    background-color: var(--bg-button-action);
    color: var(--text-light);
}

body.pastel-yellow-mode .custom-dialog .dialog-cancel-btn,
body.pastel-rainbow-mode .custom-dialog .dialog-cancel-btn {
    color: var(--text-light);
}

.custom-dialog .dialog-cancel-btn:hover:not(:disabled) {
    background-color: var(--bg-button-action-hover);
}

/* ── ファイル添付ダイアログ ── */
#fileUploadDialog {
    min-width: 320px;
    max-width: 600px;
    width: 90%;
}

.dialog-content {
    margin-bottom: 20px;
}

.file-upload-area {
    margin-bottom: 15px;
    text-align: center;
}

.file-upload-area .dialog-button {
    padding: 10px 20px;
    font-size: 14px;
}

.file-upload-area #select-files-btn {
    background-color: var(--bg-dialog-button-select);
}

.file-upload-area #select-files-btn:hover {
    background-color: var(--bg-dialog-button-select-hover);
}

#selected-files-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-secondary);
    border-radius: 5px;
    background-color: var(--bg-secondary);
    transition:
        background-color 0.3s ease,
        border-color 0.3s ease;
}

.selected-file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-dialog-file-item);
    background-color: var(--bg-dialog-file-item);
    transition:
        background-color 0.3s ease,
        border-color 0.3s ease;
}

.selected-file-item:last-child {
    border-bottom: none;
}

.selected-file-info {
    flex-grow: 1;
    overflow: hidden;
    margin-right: 10px;
}

.selected-file-name {
    display: block;
    font-size: 14px;
    color: var(--text-dialog-file-name);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.selected-file-size {
    display: block;
    font-size: 11px;
    color: var(--text-dialog-file-size);
}

.remove-file-btn {
    background-color: var(--bg-button-delete);
    color: var(--text-light);
    border: none;
    border-radius: 15%;
    width: 22px;
    height: 22px;
    min-width: 0 !important;
    font-size: 14px;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

body.pastel-yellow-mode .remove-file-btn,
body.pastel-rainbow-mode .remove-file-btn {
    color: var(--text-light);
}

.remove-file-btn:hover {
    background-color: var(--bg-button-delete-hover);
}

#file-upload-notice {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 10px;
    text-align: center;
}

#fileUploadDialog .dialog-actions {
    margin-top: 20px;
}

#fileUploadDialog .dialog-actions #confirm-attach-btn {
    background-color: var(--bg-dialog-button-confirm);
}

#fileUploadDialog .dialog-actions #confirm-attach-btn:hover:not(:disabled) {
    background-color: var(--bg-dialog-button-confirm-hover);
}

#fileUploadDialog .dialog-actions #cancel-attach-btn {
    background-color: var(--bg-dialog-button-cancel);
}

#fileUploadDialog .dialog-actions #cancel-attach-btn:hover:not(:disabled) {
    background-color: var(--bg-button-cancel-hover);
}

/* ── 画像プレビューダイアログ ── */
#imagePreviewDialog .dialog-content {
    padding: 0;
    margin: 0;
    max-height: 80vh;
    overflow: auto;
    text-align: center;
}

#imagePreviewDialog img {
    max-width: 100%;
    max-height: 75vh;
    display: block;
    margin: 0 auto;
}

#imagePreviewDialog .dialog-actions {
    margin-top: 15px;
}

/* ── 特殊ボタン ── */
.orange-button {
    background-color: var(--bg-button-edit);
    color: var(--text-light);
}

.orange-button:hover:not(:disabled) {
    background-color: var(--bg-button-edit-hover);
}

body.dark-mode .orange-button {
    background-color: var(--bg-button-edit);
    color: var(--text-light);
}

body.dark-mode .orange-button:hover:not(:disabled) {
    background-color: var(--bg-button-edit-hover);
}

body.pastel-pink-mode .orange-button,
body.pastel-blue-mode .orange-button,
body.pastel-yellow-mode .orange-button,
body.pastel-purple-mode .orange-button,
body.pastel-rainbow-mode .orange-button {
    background-color: var(--bg-button-edit);
    color: var(--text-light);
}

body.pastel-pink-mode .orange-button:hover:not(:disabled),
body.pastel-blue-mode .orange-button:hover:not(:disabled),
body.pastel-yellow-mode .orange-button:hover:not(:disabled),
body.pastel-purple-mode .orange-button:hover:not(:disabled),
body.pastel-rainbow-mode .orange-button:hover:not(:disabled) {
    background-color: var(--bg-button-edit-hover);
}

body.pastel-yellow-mode .orange-button {
    color: #ffffff;
}

.danger-zone .orange-button {
    margin-top: 10px;
    width: 100%;
}

.history-action-button.gold {
    background-color: var(--bg-button-gold);
    color: var(--text-button-gold);
}

.history-action-button.gold:hover:not(:disabled) {
    background-color: var(--bg-button-gold-hover);
}

.custom-dialog .history-action-button.gold {
    background-color: var(--bg-button-gold);
    color: var(--text-button-gold);
}

.custom-dialog .history-action-button.gold:hover:not(:disabled) {
    background-color: var(--bg-button-gold-hover);
}

.history-action-button.purple {
    background-color: var(--bg-button-purple);
    color: var(--text-button-purple);
}

.history-action-button.purple:hover:not(:disabled) {
    background-color: var(--bg-button-purple-hover);
}

body.dark-mode .history-action-button.gold {
    background-color: var(--bg-button-gold);
    color: var(--text-button-gold);
}

body.dark-mode .history-action-button.gold:hover:not(:disabled) {
    background-color: var(--bg-button-gold-hover);
}

body.dark-mode .history-action-button.purple {
    background-color: var(--bg-button-purple);
    color: var(--text-button-purple);
}

body.dark-mode .history-action-button.purple:hover:not(:disabled) {
    background-color: var(--bg-button-purple-hover);
}

body.pastel-pink-mode .history-action-button.gold,
body.pastel-blue-mode .history-action-button.gold,
body.pastel-yellow-mode .history-action-button.gold,
body.pastel-purple-mode .history-action-button.gold,
body.pastel-rainbow-mode .history-action-button.gold {
    background-color: var(--bg-button-gold);
    color: var(--text-button-gold);
}

body.pastel-pink-mode .history-action-button.gold:hover:not(:disabled),
body.pastel-blue-mode .history-action-button.gold:hover:not(:disabled),
body.pastel-yellow-mode .history-action-button.gold:hover:not(:disabled),
body.pastel-purple-mode .history-action-button.gold:hover:not(:disabled),
body.pastel-rainbow-mode .history-action-button.gold:hover:not(:disabled) {
    background-color: var(--bg-button-gold-hover);
}

body.pastel-pink-mode .history-action-button.purple,
body.pastel-blue-mode .history-action-button.purple,
body.pastel-yellow-mode .history-action-button.purple,
body.pastel-purple-mode .history-action-button.purple,
body.pastel-rainbow-mode .history-action-button.purple {
    background-color: var(--bg-button-purple);
    color: var(--text-button-purple);
}

body.pastel-pink-mode .history-action-button.purple:hover:not(:disabled),
body.pastel-blue-mode .history-action-button.purple:hover:not(:disabled),
body.pastel-yellow-mode .history-action-button.purple:hover:not(:disabled),
body.pastel-purple-mode .history-action-button.purple:hover:not(:disabled),
body.pastel-rainbow-mode .history-action-button.purple:hover:not(:disabled) {
    background-color: var(--bg-button-purple-hover);
}

.history-item-actions .js-link-session-btn:hover:not(:disabled) {
    background-color: var(--bg-button-action-hover) !important;
}

.history-item-actions .js-link-session-btn.linked-a {
    background-color: var(--bg-button-save) !important;
    color: var(--text-light) !important;
}

.history-item-actions .js-link-session-btn.linked-a:hover:not(:disabled) {
    background-color: var(--bg-button-save-hover) !important;
}

.history-item-actions .js-link-session-btn.linked-b {
    background-color: var(--bg-button-copy) !important;
    color: var(--text-light) !important;
}

.history-item-actions .js-link-session-btn.linked-b:hover:not(:disabled) {
    background-color: var(--bg-button-copy-hover) !important;
}

.interactive-title-content-style {
    margin-left: 3px;
    font-size: 0.9em;
    color: var(--text-secondary);
}

body.elevation-enabled .custom-dialog {
    box-shadow: var(--elevation-shadow-3);
}
