/* 貼文管理系統樣式 - ES2022+ 相容 */

/* Windows 11 動畫偏好設定支援 */
@media (prefers-reduced-motion: reduce) {
    /* 移除所有動畫和過渡效果 */
    .post-card,
    .post-card-list,
    .post-card-compact,
    .post-action-btn,
    .edit-post-modal,
    .delete-confirm-modal,
    .search-result,
    .system-loading-overlay,
    .post-fallback-modal {
        animation: none !important;
        transition: none !important;
        transform: none !important;
    }
    
    /* 確保所有元素始終可見 */
    .post-card,
    .post-card-list,
    .post-card-compact,
    .post-action-btn,
    .post-card-actions,
    .search-result,
    .search-no-results {
        opacity: 1 !important;
        visibility: visible !important;
        display: initial !important;
    }

    /* 特別處理動作按鈕 */
    .post-card-actions {
        display: flex !important;
    }

    /* 移除 Hover 動畫但保持功能 */
    .post-card:hover,
    .post-action-btn:hover {
        transform: none !important;
        animation: none !important;
        transition: none !important;
    }
}

/* 貼文卡片增強樣式 */
.post-card,
.post-card-list,
.post-card-compact {
    position: relative;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.post-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

/* 貼文動作按鈕 */
.post-card-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 10;
}

.post-card:hover .post-card-actions {
    opacity: 1;
}

.post-action-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.post-action-btn:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.1);
}

.post-action-btn.edit-btn {
    color: #2196F3;
}

.post-action-btn.edit-btn:hover {
    background: #E3F2FD;
    color: #1976D2;
}

.post-action-btn.delete-btn {
    color: #F44336;
}

.post-action-btn.delete-btn:hover {
    background: #FFEBEE;
    color: #D32F2F;
}

/* 檢視模式樣式 */
.view-mode-list .posts-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.post-card-list {
    display: flex;
    flex-direction: row;
    height: 120px;
    max-width: 100%;
}

.post-card-list .post-card-image {
    width: 180px;
    height: 120px;
    object-fit: cover;
    flex-shrink: 0;
}

.post-card-list .post-card-content {
    flex: 1;
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.view-mode-compact .posts-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.post-card-compact {
    height: 140px;
}

.post-card-compact .post-card-image {
    height: 80px;
}

.post-card-compact .post-card-content {
    padding: 8px 12px;
}

.post-card-compact .post-card-title {
    font-size: 0.9rem;
    line-height: 1.3;
}

/* 貼文元資料 */
.post-card-meta {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    font-size: 0.85rem;
    color: #666;
}

.post-card-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.post-author::before {
    content: "👤";
}

.post-category {
    background: #E3F2FD;
    color: #1976D2;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 500;
}

.post-date::before {
    content: "📅";
}

/* 編輯模態框樣式 */
.edit-post-modal-overlay,
.delete-confirm-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.edit-post-modal-overlay.show,
.delete-confirm-modal-overlay.show {
    opacity: 1;
}

.edit-post-modal,
.delete-confirm-modal {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.3);
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s ease;
}

.edit-post-modal-overlay.show .edit-post-modal,
.delete-confirm-modal-overlay.show .delete-confirm-modal {
    transform: scale(1) translateY(0);
}

.edit-post-modal {
    width: 800px;
}

.delete-confirm-modal {
    width: 500px;
    padding: 24px;
}

/* 編輯模態框標題 */
.edit-post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 24px 0;
    border-bottom: 1px solid #E0E0E0;
    margin-bottom: 24px;
}

.edit-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.unsaved-indicator {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #FFF3E0;
    color: #F57C00;
    border: 1px solid #FFB74D;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

/* 刪除確認對話框 */
.delete-warning-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.delete-warning-icon svg {
    color: #FF9800;
}

.delete-warning-message {
    margin-bottom: 24px;
}

.warning-text {
    font-size: 1.1rem;
    color: #333;
    margin-bottom: 16px;
    text-align: center;
}

.post-preview-card {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: #F5F5F5;
    border-radius: 12px;
    margin: 16px 0;
}

.post-preview-image {
    width: 80px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
}

.post-preview-info h4 {
    margin: 0 0 8px 0;
    font-size: 1rem;
}

.post-meta {
    display: flex;
    gap: 16px;
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 8px;
}

.delete-consequences {
    background: #FFEBEE;
    border: 1px solid #FFCDD2;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 24px;
}

.delete-consequences h4 {
    color: #D32F2F;
    margin: 0 0 12px 0;
}

.delete-consequences ul {
    margin: 0;
    padding-left: 20px;
    color: #666;
}

.delete-consequences li {
    margin-bottom: 4px;
}

.confirmation-checkbox {
    margin: 24px 0;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    font-size: 0.95rem;
    line-height: 1.4;
}

.checkbox-label input[type="checkbox"] {
    margin: 0;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.delete-confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

.btn-danger {
    background: #F44336;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn-danger:hover:not(:disabled) {
    background: #D32F2F;
    transform: translateY(-2px);
}

.btn-danger:disabled {
    background: #BDBDBD;
    cursor: not-allowed;
    transform: none;
}

/* 批量刪除相關 */
.batch-delete-info {
    margin: 16px 0;
}

.batch-delete-info h4 {
    margin: 0 0 12px 0;
    font-size: 1rem;
    color: #333;
}

.selected-posts-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #E0E0E0;
    border-radius: 8px;
}

.batch-post-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-bottom: 1px solid #F0F0F0;
}

.batch-post-item:last-child {
    border-bottom: none;
}

.batch-post-thumb {
    width: 48px;
    height: 36px;
    object-fit: cover;
    border-radius: 6px;
}

.batch-post-info h5 {
    margin: 0 0 4px 0;
    font-size: 0.9rem;
    color: #333;
}

.batch-post-meta {
    font-size: 0.8rem;
    color: #666;
}

.batch-more-info {
    padding: 12px;
    text-align: center;
    color: #666;
    font-size: 0.9rem;
    font-style: italic;
    background: #F9F9F9;
}

/* 系統載入覆蓋層 */
.system-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
}

.loading-content {
    text-align: center;
    padding: 40px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.loading-spinner svg {
    animation: spin 1s linear infinite;
    color: #2196F3;
    margin-bottom: 16px;
}

.loading-message {
    margin: 0;
    font-size: 1.1rem;
    color: #333;
    font-weight: 500;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* 搜尋結果樣式 */
.search-result {
    position: relative;
}

.search-result-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: #4CAF50;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    z-index: 5;
}

.search-highlight {
    background: #FFEB3B;
    color: #333;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 500;
}

.search-no-results {
    text-align: center;
    padding: 80px 40px;
    color: #666;
    grid-column: 1 / -1;
}

.no-results-icon svg {
    color: #BDBDBD;
    margin-bottom: 24px;
}

.search-no-results h3 {
    margin: 0 0 16px 0;
    color: #333;
    font-size: 1.5rem;
}

.search-no-results p {
    margin: 0 0 32px 0;
    font-size: 1.1rem;
    color: #666;
}

.no-results-suggestions {
    text-align: left;
    max-width: 400px;
    margin: 0 auto 32px;
}

.no-results-suggestions h4 {
    margin: 0 0 16px 0;
    color: #333;
}

.no-results-suggestions ul {
    margin: 0;
    padding-left: 24px;
}

.no-results-suggestions li {
    margin-bottom: 8px;
    color: #666;
}

/* 後備模態框 */
.post-fallback-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.post-fallback-modal .modal-content {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.3);
}

.post-fallback-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #E0E0E0;
}

.post-fallback-modal .close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 4px;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .edit-post-modal,
    .delete-confirm-modal {
        margin: 16px;
        max-width: calc(100vw - 32px);
    }
    
    .post-card-list {
        flex-direction: column;
        height: auto;
    }
    
    .post-card-list .post-card-image {
        width: 100%;
        height: 120px;
    }
    
    .post-card-actions {
        position: relative;
        top: auto;
        right: auto;
        opacity: 1;
        justify-content: flex-end;
        padding: 12px;
        background: rgba(255, 255, 255, 0.95);
        border-top: 1px solid #E0E0E0;
    }
    
    .view-mode-compact .posts-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 8px;
    }
}

/* 高對比度支援 */
@media (prefers-contrast: high) {
    .post-card,
    .post-card-list,
    .post-card-compact {
        border: 2px solid #000;
    }
    
    .post-action-btn {
        border: 1px solid #000;
    }
    
    .search-highlight {
        background: #000;
        color: #fff;
    }
}

/* 深色模式支援 */
@media (prefers-color-scheme: dark) {
    .post-card,
    .post-card-list,
    .post-card-compact {
        background: #2E2E2E;
        color: #fff;
    }
    
    .edit-post-modal,
    .delete-confirm-modal {
        background: #1E1E1E;
        color: #fff;
    }
    
    .system-loading-overlay {
        background: rgba(0, 0, 0, 0.95);
    }
    
    .loading-content {
        background: #1E1E1E;
        color: #fff;
    }
}