/* 自定義樣式 */
:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-success: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-info: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.15);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.1);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 全局滑動動畫 */
html {
    scroll-behavior: smooth;
}

/* 全局過渡效果 */
* {
    transition: var(--transition-smooth);
}

body {
    font-family: 'Microsoft JhengHei', 'PingFang TC', 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
}

/* ========== 卡片設計 ========== */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
}

.card-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    font-weight: 600;
    padding: 1.2rem;
}

.bg-card-header-custom {
    background: #dee2e6 !important; /* Darker than bg-light */
    color: #212529;
}

.card-body {
    padding: 1.5rem;
}

/* ========== 按鈕設計 ========== */
.btn {
    border-radius: 8px;
    font-weight: 600;
    padding: 0.6rem 1.2rem;
    border: none;
    transition: var(--transition-smooth);
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
    color: white;
}

.btn-success {
    background: var(--gradient-success);
    color: white;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(245, 87, 108, 0.4);
    color: white;
}

.btn-outline-primary {
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline-primary:hover {
    background: var(--gradient-primary);
    border-color: transparent;
    color: white;
}

/* ========== 公告卡片樣式 ========== */
.announcement-card, .removable-card {
    transition: var(--transition-smooth);
    border: none;
    border-left: 4px solid var(--primary-color);
    border-radius: 10px;
    overflow: hidden;
}

.announcement-card.important-announcement {
    border-left-color: var(--warning-color);
    background: linear-gradient(to right, rgba(255, 193, 7, 0.1), transparent);
}

.announcement-card:hover, .removable-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.announcement-card.dragging, .removable-card.dragging {
    opacity: 0.5;
    transform: rotate(2deg) scale(0.98);
    z-index: 1000;
}

.sortable-container {
    min-height: 50px;
}

.sortable-container.drag-over {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    border: 2px dashed #667eea;
    border-radius: 8px;
    padding: 10px;
}

.drag-handle {
    cursor: grab;
    opacity: 0.6;
    transition: opacity 0.2s ease;
    color: #667eea;
}

.drag-handle:hover {
    opacity: 1;
}

.drag-handle:active {
    cursor: grabbing;
}

/* ========== 表格樣式 ========== */
.table {
    border-collapse: separate;
    border-spacing: 0;
}

.table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.table thead th {
    border: none;
    font-weight: 600;
    padding: 1rem;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.table tbody td {
    padding: 1rem;
    border-bottom: 1px solid #e9ecef;
    vertical-align: middle;
}

.table tbody tr {
    transition: var(--transition-smooth);
}

.table tbody tr:hover {
    background: rgba(102, 126, 234, 0.08);
    transform: scale(1.01);
}

/* ========== 徽章樣式 ========== */
.badge {
    padding: 0.5rem 0.8rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
}

.badge.bg-primary {
    background: var(--gradient-primary) !important;
}

.badge.bg-success {
    background: var(--gradient-success) !important;
}

.badge.bg-warning {
    background: #ffc107 !important;
    color: #333 !important;
}

.badge.bg-danger {
    background: linear-gradient(135deg, #f5576c 0%, #f093fb 100%) !important;
}

/* ========== Jumbotron 設計 ========== */
.jumbotron {
    background: var(--gradient-primary);
    color: white;
    border-radius: 12px;
    padding: 3rem 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-lg);
}

.jumbotron h1 {
    font-weight: 700;
    font-size: 3rem;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.jumbotron .lead {
    font-size: 1.3rem;
    opacity: 0.95;
}

.jumbotron .btn {
    margin-top: 0.5rem;
}

/* ========== 表單樣式 ========== */
.form-control, .form-select {
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    transition: var(--transition-smooth);
}

.form-control:focus, .form-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

.form-label {
    font-weight: 600;
    color: #333;
    margin-bottom: 0.5rem;
}

/* ========== 編輯器樣式 ========== */
.markdown-editor-container {
    position: relative;
}

.markdown-editor-container textarea,
.markdown-editor-container #markdown-preview,
.markdown-editor-container #markdown-preview-issue {
    border-radius: 8px;
    font-size: 14px;
    border: 2px solid #e9ecef;
    transition: var(--transition-smooth);
}

.markdown-editor-container textarea:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

/* Markdown 工具列 */
.markdown-toolbar {
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
    padding: 1rem;
    border-radius: 8px 8px 0 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.markdown-toolbar button {
    padding: 0.5rem 0.8rem;
    border: 1px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition-smooth);
    font-size: 0.9rem;
}

.markdown-toolbar button:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
    transform: translateY(-2px);
}

/* ========== 警告/提示框 ========== */
.alert {
    border: none;
    border-radius: 10px;
    border-left: 4px solid;
    padding: 1.2rem;
}

.alert-info {
    background: rgba(13, 202, 240, 0.1);
    border-left-color: #0dcaf0;
    color: #055160;
}

.alert-warning {
    background: rgba(255, 193, 7, 0.1);
    border-left-color: #ffc107;
    color: #664d03;
}

.alert-danger {
    background: rgba(220, 53, 69, 0.1);
    border-left-color: #dc3545;
    color: #842029;
}

.alert-success {
    background: rgba(25, 135, 84, 0.1);
    border-left-color: #198754;
    color: #0a3622;
}

/* ========== Markdown 內容 ========== */
.markdown-content {
    line-height: 1.8;
}

.markdown-content h1, 
.markdown-content h2, 
.markdown-content h3, 
.markdown-content h4, 
.markdown-content h5, 
.markdown-content h6 {
    color: #667eea;
    font-weight: 700;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

.markdown-content h1 {
    font-size: 2.2rem;
}

.markdown-content h2 {
    font-size: 1.8rem;
    border-bottom: 2px solid #667eea;
    padding-bottom: 0.5rem;
}

.markdown-content h3 {
    font-size: 1.4rem;
}

.markdown-content code {
    background: #f8f9fa;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    color: #e83e8c;
    font-family: 'Courier New', monospace;
}

.markdown-content pre {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 1.5rem;
    border-radius: 8px;
    overflow-x: auto;
    border-left: 4px solid #667eea;
}

.markdown-content blockquote {
    border-left: 4px solid #667eea;
    padding-left: 1.5rem;
    margin: 1.5rem 0;
    color: #666;
    font-style: italic;
}

.markdown-content ul, 
.markdown-content ol {
    margin: 1rem 0;
    padding-left: 2rem;
}

.markdown-content ul li, 
.markdown-content ol li {
    margin: 0.5rem 0;
}

.markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    border-radius: 8px;
    overflow: hidden;
}

.markdown-content table th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
}

.markdown-content table td {
    border-bottom: 1px solid #e9ecef;
    padding: 0.8rem 1rem;
}

.markdown-content table tr:hover {
    background: rgba(102, 126, 234, 0.05);
}

/* ========== 統計卡片 ========== */
.stat-card {
    text-align: center;
    padding: 2rem 1rem;
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    border-top: 4px solid #667eea;
}

.stat-card h5 {
    font-size: 2.5rem;
    font-weight: 700;
    color: #667eea;
    margin: 0;
}

.stat-card small {
    color: #666;
    font-size: 0.95rem;
}

.stat-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
}

/* ========== 深色模式主題 ========== */
[data-bs-theme="dark"] {
    --bs-body-bg: #1a1a1a;
    --bs-body-color: #e0e0e0;
}

[data-bs-theme="dark"] body {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
}

[data-bs-theme="dark"] .navbar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    box-shadow: var(--shadow-md);
}

[data-bs-theme="dark"] .jumbotron {
    background: var(--gradient-primary);
}

[data-bs-theme="dark"] .card {
    background-color: #2d2d2d;
    color: #e0e0e0;
    border: 1px solid #404040;
}

[data-bs-theme="dark"] .card-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-bottom: none;
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: #404040;
    color: #e0e0e0;
    border-color: #505050;
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    background-color: #404040;
    color: #e0e0e0;
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

[data-bs-theme="dark"] .table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

[data-bs-theme="dark"] .table tbody tr:hover {
    background: rgba(102, 126, 234, 0.15);
}

[data-bs-theme="dark"] .markdown-editor-container textarea {
    background-color: #404040;
    color: #e0e0e0;
    border-color: #505050;
}

[data-bs-theme="dark"] .markdown-toolbar {
    background: #404040;
    border-color: #505050;
}

[data-bs-theme="dark"] .markdown-toolbar button {
    background: #505050;
    color: #e0e0e0;
    border-color: #606060;
}

[data-bs-theme="dark"] .markdown-toolbar button:hover {
    background: #667eea;
    border-color: #667eea;
}

[data-bs-theme="dark"] .markdown-content h1,
[data-bs-theme="dark"] .markdown-content h2,
[data-bs-theme="dark"] .markdown-content h3,
[data-bs-theme="dark"] .markdown-content h4,
[data-bs-theme="dark"] .markdown-content h5,
[data-bs-theme="dark"] .markdown-content h6 {
    color: #667eea;
}

[data-bs-theme="dark"] .markdown-content code {
    background: #404040;
    color: #ff79c6;
}

/* ========== 響應式設計 ========== */
@media (max-width: 768px) {
    .jumbotron h1 {
        font-size: 2rem;
    }

    .jumbotron .lead {
        font-size: 1rem;
    }

    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }

    .card-header {
        padding: 1rem;
    }

    .table {
        font-size: 0.9rem;
    }

    .table thead th,
    .table tbody td {
        padding: 0.75rem 0.5rem;
    }
}

@media (max-width: 576px) {
    .jumbotron {
        padding: 1.5rem 1rem;
    }

    .jumbotron h1 {
        font-size: 1.5rem;
    }

    .markdown-toolbar {
        flex-direction: column;
    }

    .markdown-toolbar button {
        width: 100%;
    }

    .stat-card {
        margin-bottom: 1rem;
    }

    .stat-card h5 {
        font-size: 2rem;
    }
}

/* ========== 動畫效果 ========== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.card {
    animation: fadeInUp 0.6s ease-out;
}

.btn-primary, .btn-success {
    animation: slideInLeft 0.6s ease-out;
}

/* ========== 深色模式切換按鈕 ========== */
.theme-toggle-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    z-index: 999;
    transition: all 0.3s ease;
}

.theme-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

[data-bs-theme="dark"] .theme-toggle-btn {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.4);
}

[data-bs-theme="dark"] .theme-toggle-btn:hover {
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.6);
}

/* ========== 鏈接樣式 ========== */
a {
    text-decoration: none !important;
    color: inherit;
}

a:hover {
    color: #667eea;
}

/* ========== 日期時間樣式 ========== */
.text-muted small,
small.text-muted {
    color: #6c757d; /* 標準 Bootstrap 灰色 */
    opacity: 0.8;
}

[data-bs-theme="dark"] .text-muted small,
[data-bs-theme="dark"] small.text-muted {
    color: #ced4da; /* 深色模式下較亮的灰色 */
}

.getFormattedTimestamp,
[class*="timestamp"] {
    color: inherit;
}

/* ========== 視圖計數樣式 ========== */
.view-count-text {
    color: #adb5bd !important;
    font-weight: 500;
}

/* ========== 輔助類 ========== */
.text-gradient {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
}

/* ========== 卡片標題編輯框樣式 ========== */
.card-title-editable {
    background-color: #f8f9fa !important;
    border: 1px solid #ced4da !important;
    border-radius: 4px !important;
    padding: 0.375rem 0.75rem !important;
    font-weight: 500 !important;
}

.card-title-editable:focus {
    background-color: #fff !important;
    border-color: #667eea !important;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25) !important;
}

/* ========== 管理員回覆樣式 ========== */
.admin-reply-card {
    border-top: 4px solid #28a745 !important;
}

.admin-reply-header {
    background-color: #d4edda !important;
    color: #155724 !important;
}

.admin-reply-content {
    background-color: #f8f9fa !important;
    color: #212529 !important;
}

.shadow-soft {
    box-shadow: var(--shadow-md);
}

.shadow-strong {
    box-shadow: var(--shadow-lg);
}

.rounded-xl {
    border-radius: 12px;
}

.transition-smooth {
    transition: var(--transition-smooth);
}