/* ===================================
   Discord 訊息監控系統 - 功能模塊
   ================================ */

/* ===== 訊息項目 ===== */
.message-item, .forum-item {
    background: white;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
}

.message-item:hover, .forum-item:hover {
    transform: translateX(5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
}

.message-item.action-send, .forum-item.action-create {
    border-left-color: var(--success-color);
}

.message-item.action-edit, .forum-item.action-update {
    border-left-color: var(--warning-color);
}

.message-item.action-delete, .forum-item.action-delete {
    border-left-color: var(--danger-color);
}

.message-header, .forum-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    object-fit: cover;
}

.message-meta, .forum-meta {
    flex: 1;
}
/* 在 features.css 末尾添加圖片錯誤處理樣式 */

/* ===== 圖片錯誤處理樣式 ===== */
.image-error {
    border: 2px dashed #dc3545 !important;
    background: #f8d7da !important;
    opacity: 0.8;
    transition: all 0.3s ease;
}

.image-error:hover {
    opacity: 1;
    transform: scale(1.02);
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.3);
}

/* 載入中的圖片 */
.attachment-image.loading {
    opacity: 0.6;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* 圖片載入錯誤提示 */
.image-error-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(220, 53, 69, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.image-error-overlay:hover {
    background: rgba(220, 53, 69, 0.2);
}

.image-error-icon {
    font-size: 24px;
    color: #dc3545;
    margin-bottom: 8px;
}

.image-error-text {
    color: #721c24;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    line-height: 1.2;
}

.image-retry-text {
    color: #856404;
    font-size: 10px;
    margin-top: 4px;
    opacity: 0.8;
}

/* 頭像錯誤處理 */
.avatar.image-error {
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #721c24;
    font-weight: bold;
}

/* 附件圖片錯誤處理 */
.attachment-image.image-error {
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    text-align: center;
    padding: 10px;
}

.attachment-image.image-error::before {
    content: '🚫';
    font-size: 32px;
    margin-bottom: 8px;
    display: block;
}

.attachment-image.image-error::after {
    content: '圖片已失效\A點擊重試';
    white-space: pre-line;
    font-size: 11px;
    color: #721c24;
    font-weight: 600;
    line-height: 1.2;
}

/* 模態框圖片錯誤處理 */
.image-modal-img.image-error {
    border-radius: 12px;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    text-align: center;
    background: #f8d7da;
    color: #721c24;
}

.image-modal-img.image-error::before {
    content: '🚫';
    font-size: 64px;
    margin-bottom: 16px;
    display: block;
}

.image-modal-img.image-error::after {
    content: '圖片載入失敗\ADiscord 圖片連結可能已過期\A點擊重試或嘗試下載原圖';
    white-space: pre-line;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
}

/* 成功重新載入的動畫 */
.image-success {
    animation: imageSuccess 0.5s ease-out;
}

@keyframes imageSuccess {
    0% {
        opacity: 0;
        transform: scale(0.9);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* 圖片重試按鈕 */
.image-retry-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(220, 53, 69, 0.9);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
}

.image-retry-btn:hover {
    background: rgba(220, 53, 69, 1);
    transform: translate(-50%, -50%) scale(1.05);
}

/* 載入狀態的淡入效果 */
.attachment-image {
    transition: opacity 0.3s ease, filter 0.3s ease;
}

.attachment-image.loading {
    opacity: 0.6;
    filter: blur(1px);
}

/* 錯誤狀態的通知樣式 */
.image-error-notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #dc3545;
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
    z-index: 10000;
    animation: slideInUp 0.3s ease-out;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* 用戶名稱樣式 */
.author-name {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.clickable-author {
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    color: var(--text-primary);
    padding: 2px 6px;
    border-radius: 6px;
    position: relative;
}

.clickable-author:hover {
    background: #4f46e5;
    color: white;
    transform: translateY(-1px);
}

.author-handle {
    color: var(--text-secondary);
    font-size: 0.9em;
    font-weight: 400;
}

.message-time, .thread-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.thread-title {
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 4px;
    line-height: 1.4;
}

/* 點擊標題樣式 */
.clickable-thread-title {
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 2px 4px;
    border-radius: 4px;
    display: inline-block;
}

.clickable-thread-title:hover {
    background-color: rgba(76, 81, 191, 0.1);
    color: var(--primary-dark);
    transform: translateX(2px);
}

/* 內容區塊 */
.message-content, .forum-content {
    background: var(--bg-secondary);
    padding: 16px;
    border-radius: var(--border-radius);
    border-left: 3px solid var(--info-color);
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    max-height: 120px;
    overflow-y: auto;
    margin-top: 8px;
	margin-bottom: 10px;
    backdrop-filter: blur(10px);
    line-height: 1.5;
    font-size: 14px;
    color: #1e293b;
}

.original-content {
    background: linear-gradient(135deg, #fef3c7, #fed7aa);
    padding: 15px;
    border-radius: var(--border-radius);
    margin: 15px 0;
    border-left: 4px solid var(--warning-color);
    border: 1px solid #fbbf24;
}

.original-content-label {
    font-weight: 700;
    color: #92400e;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.original-content-text {
    color: #78350f;
    line-height: 1.6;
}

.reply-content {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    padding: 15px;
    border-radius: var(--border-radius);
    margin: 15px 0;
    border-left: 4px solid var(--info-color);
    border: 1px solid #60a5fa;
}

.reply-label {
    font-weight: 700;
    color: #1e40af;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.reply-text {
    color: #1e3a8a;
    line-height: 1.6;
}

/* ===== 附件樣式 ===== */
.attachments-section {
    background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
    padding: 20px;
    border-radius: 16px;
    margin: 15px 0;
    border: 1px solid #0ea5e9;
}

.attachments-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.attachments-label {
    font-weight: 700;
    color: #0c4a6e;
    font-size: 1rem;
}

.btn-download-all {
    background: linear-gradient(135deg, #059669, #047857);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-download-all:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

.attachments-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 15px;
}

.attachments-grid.single-attachment {
    grid-template-columns: minmax(200px, 300px);
    justify-content: start;
}

.attachment-item {
    background: white;
    border-radius: var(--border-radius);
    padding: 12px;
    border: 2px solid #e2e8f0;
    transition: all 0.3s ease;
    position: relative;
}

.attachment-item:hover {
    border-color: var(--info-color);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.15);
}

.image-attachment .attachment-image-container {
    position: relative;
    margin-bottom: 10px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
}

.attachment-image {
    width: 100%;
    height: 120px;
    border-radius: 8px;
    object-fit: cover;
    transition: all 0.3s ease;
}

.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.attachment-image-container:hover .image-overlay {
    opacity: 1;
}

.zoom-icon {
    font-size: 24px;
    color: white;
}

.file-attachment .attachment-file {
    font-size: 48px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 8px;
    margin-bottom: 10px;
}

.attachment-info {
    text-align: center;
}

.attachment-name {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #475569;
}

.attachment-size {
    font-size: 11px;
    color: #64748b;
    margin-bottom: 8px;
}

.attachment-download {
    background: var(--info-color);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}

.attachment-download:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

/* ===== 動作標籤 ===== */
.action-badge {
    padding: 6px 14px;
    border-radius: 25px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 2px solid;
}

.action-badge.action-send, .action-badge.action-create {
    background: linear-gradient(135deg, var(--success-color), #059669);
    color: white;
    border-color: var(--success-color);
}

.action-badge.action-edit, .action-badge.action-update {
    background: linear-gradient(135deg, var(--warning-color), #d97706);
    color: white;
    border-color: var(--warning-color);
}

.action-badge.action-delete {
    background: linear-gradient(135deg, var(--danger-color), #dc2626);
    color: white;
    border-color: var(--danger-color);
}

/* ===== 訊息連結 ===== */
.message-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
	margin-top: 10px;
    color: var(--text-secondary);
}

.message-links {
    display: flex;
    gap: 10px;
    align-items: center;
}

.discord-app-link {
    background: linear-gradient(135deg, #5865f2, #7289da);
    color: white !important;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.discord-app-link:hover {
    background: linear-gradient(135deg, #4752c4, #677bc4);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(88, 101, 242, 0.3);
}

.message-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    font-size: 12px;
}

.message-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* ===== 通知系統 ===== */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border-radius: var(--border-radius);
    padding: 16px 20px;
    box-shadow: var(--shadow-lg);
    max-width: 400px;
    z-index: 10000;
    transform: translateX(120%);
    transition: all 0.3s ease;
    border-left: 4px solid var(--success-color);
}

.notification.show {
    transform: translateX(0);
}

.notification.success { border-left-color: var(--success-color); }
.notification.error { border-left-color: var(--danger-color); }
.notification.warning { border-left-color: var(--warning-color); }
.notification.info { border-left-color: var(--info-color); }

/* 搜尋通知 */
.channel-search-notification,
.author-search-notification,
.thread-search-notification {
    background: var(--primary-gradient);
    color: white;
    padding: 12px 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    animation: slideInDown 0.5s ease-out;
}

.thread-to-message-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, var(--success-color), #059669);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.3);
    z-index: 10000;
    display: flex;
    align-items: center;
    font-weight: 500;
    max-width: 90vw;
}

.channel-search-notification span,
.author-search-notification span {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.channel-search-notification button,
.author-search-notification button {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.3s ease;
}

.channel-search-notification button:hover,
.author-search-notification button:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ===== 載入和錯誤狀態 ===== */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid var(--bg-accent);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
    margin: 0 auto 20px;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(2px);
}

.loading-content {
    background: white;
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.error-message {
    background: #fee2e2;
    color: var(--danger-color);
    padding: 15px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    border-left: 4px solid var(--danger-color);
    font-weight: 500;
}

.no-results {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.no-results-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.3;
}

.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 5rem;
    margin-bottom: 20px;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.empty-state p {
    font-size: 1rem;
    margin-bottom: 20px;
}