/* 統一模態框樣式系統 - 通用樣式 */

/* CSS 變數 */
:root {
    --modal-bg-color: rgba(65, 70, 81, 0.7);
    --modal-content-bg: #FFFFFF;
    --modal-border-color: #E9EAEB;
    --modal-text-color: #181D27;
    --modal-text-muted: #535862;
    --modal-text-light: #717680;
    --modal-icon-color: #079455;
    --modal-icon-bg: #DCFAE6;
    --modal-icon-border: #ECFDF3;
    --modal-button-color: #A4A7AE;
    --modal-shadow: 0px 3px 3px -1.5px rgba(10, 13, 18, 0.04),
                    0px 8px 8px -4px rgba(10, 13, 18, 0.03),
                    0px 20px 24px -4px rgba(10, 13, 18, 0.08);
}

/* 模態框基礎樣式 */
.modal-overlay,
.modal-common {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--modal-bg-color);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 32px;
}

.modal-container {
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-content,
.modal-content-common,
.edit-modal-content {
    background: var(--modal-content-bg);
    border-radius: 16px;
    box-shadow: var(--modal-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 編輯模態框特定尺寸 */
.edit-modal-content {
    max-width: 600px;
    width: 90vw;
    max-height: 90vh;
}

/* 模態框頭部樣式 */
.modal-header,
.edit-modal-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 24px 24px 0px;
    flex-shrink: 0;
}

.edit-modal-header {
    justify-content: space-between;
    align-items: center;
}

.modal-icon {
    width: 48px;
    height: 48px;
    background: var(--modal-icon-bg);
    border: 8px solid var(--modal-icon-border);
    border-radius: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--modal-icon-color);
    font-size: 24px;
}

.header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.modal-title-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* 標題樣式 */
.modal-title {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 16px;
    line-height: 1.5;
    color: var(--modal-text-color);
    margin: 0;
}

.edit-modal-header .modal-title {
    font-size: 18px;
    line-height: 1.5555555555555556em;
}

.modal-subtitle {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 14px;
    line-height: 1.428571429;
    color: var(--modal-text-muted);
    margin: 0;
}

/* 關閉按鈕樣式 */
.modal-close-btn,
.close-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--modal-button-color);
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
    padding: 8px;
}

.modal-close-btn:hover,
.close-btn:hover {
    background: rgba(164, 167, 174, 0.1);
}

/* 模態框主體樣式 */
.modal-body,
.edit-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px 0px;
    min-height: 0;
}

.edit-modal-body {
    padding: 20px 24px;
    max-height: 60vh;
}

/* 模態框底部樣式 */
.modal-footer,
.edit-modal-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 24px;
    flex-shrink: 0;
    margin-top: auto;
}

.edit-modal-actions {
    justify-content: flex-end;
}

.footer-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 表單輸入容器樣式 */
.input-container {
    background: #FAFAFA;
    border: 1px solid #D5D7DA;
    border-radius: 8px;
    box-shadow: 0px 1px 2px 0px rgba(10, 13, 18, 0.05);
    overflow: hidden;
}

.input-wrapper {
    position: relative;
    padding: 12px 14px;
}

.title-input {
    width: 100%;
    border: none;
    background: transparent;
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 16px;
    line-height: 1.5;
    color: var(--modal-text-color);
    outline: none;
    resize: none;
}

.title-input::placeholder {
    color: var(--modal-text-light);
}

.divider {
    height: 1px;
    background: #E5E7EB;
    margin: 0 14px;
}

/* 內容編輯器樣式 */
.content-wrapper {
    position: relative;
    padding: 12px 14px;
    min-height: 120px;
}

.content-editor {
    width: 100%;
    min-height: 120px;
    border: none;
    background: transparent;
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 16px;
    line-height: 1.5;
    color: var(--modal-text-color);
    outline: none;
    resize: none;
    overflow-y: auto;
    max-height: 300px;
}

.content-editor:empty:before {
    content: attr(placeholder);
    color: var(--modal-text-light);
    pointer-events: none;
    position: absolute;
}

/* 增強輸入框樣式 */
.enhanced-input {
    border: 2px solid #BE9F34;
    background-color: var(--modal-content-bg);
    box-shadow: 0px 1px 2px 0px rgba(10, 13, 18, 0.05);
    border-radius: 8px;
    padding: 12px 14px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    transition: all 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}

.enhanced-input:focus-within {
    border-color: #BE9F34;
}

.input-content-wrapper {
    flex: 1;
    display: flex;
    align-items: stretch;
    padding: 2px 0;
}

.message-input {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    min-height: 20px;
    max-height: 100px;
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 16px;
    line-height: 1.5em;
    color: var(--modal-text-color);
    background-color: transparent;
    padding: 0;
    overflow-y: hidden;
    width: 100%;
}

.message-input::placeholder {
    color: var(--modal-text-color);
}

.message-input:focus { 
    outline: none;
    box-shadow: none;
}

.message-input-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

.utilities {
    display: flex;
    align-items: center;
    gap: 2px;
}

/* 圖片上傳按鈕樣式 */
.image-upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--modal-button-color);
    cursor: pointer;
    transition: all 0.15s ease;
}

.image-upload-btn:hover {
    background: rgba(164, 167, 174, 0.1);
    color: var(--modal-text-muted);
}

/* 編輯模態框中的圖片上傳按鈕 */
.edit-modal-body .image-upload-btn {
    width: 28px;
    height: 28px;
    padding: 6px;
}

.edit-modal-body .image-upload-btn i {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* 圖片預覽容器樣式 */
.image-preview-container,
#edit-comment-image-preview-container {
    display: none;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding: 0 0 12px 0;
    gap: 8px;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.image-preview-container:not(.empty),
#edit-comment-image-preview-container:not(.empty) {
    display: flex !important;
}

.image-preview-container.drag-highlight,
#edit-comment-image-preview-container.drag-highlight {
    border: 2px dashed #FBBF24;
    background-color: #FFFBEB;
    border-radius: 8px;
    padding: 8px;
}

/* 圖片預覽項目樣式 */
.image-preview-item {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    opacity: 1;
    transform: scale(1);
    transition: all 0.2s ease;
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview-item.existing-image {
    border: 2px solid #10B981;
}

.image-preview-item.new-image {
    border: 2px solid #F59E0B;
}

/* 圖片刪除按鈕樣式 */
.image-preview-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: all 0.2s ease;
}

.image-preview-remove:hover {
    background-color: rgba(220, 38, 38, 0.9);
    opacity: 1;
    transform: scale(1.1);
}

.image-preview-item:hover .image-preview-remove {
    opacity: 1;
}

/* 圖片類型指示器 */
.image-type-indicator {
    position: absolute;
    bottom: 4px;
    left: 4px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    color: white;
    text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.5);
    opacity: 0.9;
    transition: opacity 0.2s ease;
}

.image-type-indicator.existing {
    background: rgba(16, 185, 129, 0.8);
}

.image-type-indicator.new {
    background: rgba(245, 158, 11, 0.8);
}

.image-preview-item:hover .image-type-indicator {
    opacity: 1;
}

/* 通知訊息樣式 */
.warning-message {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    margin-top: 8px;
    background: #FEF3C7;
    border: 1px solid #F59E0B;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 12px;
    line-height: 1.5;
    color: #D97706;
    animation: fadeIn 0.3s ease-out;
}

.warning-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.error-message {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #FEE2E2;
    border: 1px solid #F87171;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 14px;
    color: #DC2626;
    margin-top: 8px;
}

.error-icon {
    color: #DC2626;
    flex-shrink: 0;
}

.error-text {
    flex: 1;
}

/* 上傳進度條樣式 */
.upload-progress {
    margin-top: 8px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--modal-border-color);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--modal-icon-color);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 14px;
    line-height: 1.428571429;
    color: var(--modal-text-muted);
    margin: 4px 0 0 0;
}

/* 拖拽上傳樣式 */
.content-editor.drag-over {
    border: 2px dashed #3B82F6 !important;
    background: #EFF6FF !important;
    position: relative;
}

.content-editor.drag-over::after {
    content: "拖拽圖片到此處上傳";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(59, 130, 246, 0.9);
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    pointer-events: none;
    z-index: 1000;
    white-space: nowrap;
}

/* 通用動畫 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* 載入按鈕樣式 */
.btn-loading {
    position: relative;
    color: transparent;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    border: 2px solid #FFFFFF;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* 通用工具類 */
.hidden {
    display: none !important;
}

/* 滾動條樣式 */
.modal-body::-webkit-scrollbar,
.edit-modal-body::-webkit-scrollbar,
.image-preview-container::-webkit-scrollbar,
#edit-comment-image-preview-container::-webkit-scrollbar {
    width: 6px;
    height: 4px;
}

.modal-body::-webkit-scrollbar-track,
.edit-modal-body::-webkit-scrollbar-track {
    background: #F5F5F5;
    border-radius: 3px;
}

.image-preview-container::-webkit-scrollbar-track,
#edit-comment-image-preview-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 2px;
}

.modal-body::-webkit-scrollbar-thumb,
.edit-modal-body::-webkit-scrollbar-thumb {
    background: #D5D7DA;
    border-radius: 3px;
}

.image-preview-container::-webkit-scrollbar-thumb,
#edit-comment-image-preview-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 2px;
}

.modal-body::-webkit-scrollbar-thumb:hover,
.edit-modal-body::-webkit-scrollbar-thumb:hover {
    background: #A4A7AE;
}

.image-preview-container::-webkit-scrollbar-thumb:hover,
#edit-comment-image-preview-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.content-editor::-webkit-scrollbar {
    width: 4px;
}

.content-editor::-webkit-scrollbar-track {
    background: transparent;
}

.content-editor::-webkit-scrollbar-thumb {
    background: #D5D7DA;
    border-radius: 2px;
}

.content-editor::-webkit-scrollbar-thumb:hover {
    background: #A4A7AE;
}

/* 響應式設計 */
@media (max-width: 576px ) {
    .modal-overlay,
    .modal-common {
        padding: 16px;
    }

    .modal-header,
    .edit-modal-header {
        padding: 16px 16px 0px;
    }

    .modal-body,
    .edit-modal-body {
        padding: 16px 16px 0px;
    }

    .edit-modal-body {
        padding: 16px;
    }

    .modal-footer,
    .edit-modal-actions {
        padding: 24px 16px 16px;
    }


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

    .edit-modal-content {
        width: 95vw;
        max-height: 95vh;
    }

    .edit-modal-actions {
        gap: 8px;
    }

    .image-preview-item {
        width: 60px;
        height: 60px;
    }
} 