/* Tools.cshtml 專用樣式 */

/* 確保 body 不會產生水平捲軸 */
.tools-page body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    overflow-x: hidden; /* 防止水平捲軸 */
}

/* 設定 main 容器樣式，確保 Tools 頁面 */
.tools-page main {
    background: transparent;
    padding: 20px 0;
    overflow-x: hidden; /* 防止水平捲軸 */
}

/* 主要內容容器 - 防止內容溢出 */
.container-fluid {
    background: white;
    box-shadow: 0 0 30px rgba(0,0,0,0.1);
    border-radius: 20px;
    margin: 0 20px;
    padding: 1px;
    max-width: calc(100vw - 40px); /* 確保不會超出視窗寬度 */
    overflow-x: hidden; /* 防止水平捲軸 */
    box-sizing: border-box; /* 包含 padding 和 border 在寬度計算內 */
}

/* 分類區域樣式 */
.category-section {
    background: linear-gradient(135deg, #f8f9ff 0%, #f0f4ff 100%);
    border-radius: 24px;
    padding: 30px;
    margin: 20px 0;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    border: 1px solid rgba(102, 126, 234, 0.1);
    position: relative;
    overflow: visible; /* 改為 visible */
    width: 100%;
    box-sizing: border-box; /* 包含 padding 和 border 在寬度計算內 */
}

.category-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 50%, #667eea 100%);
    background-size: 200% 100%;
    animation: gradientShift 3s ease-in-out infinite;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* 區塊標題樣式 */
.section-header {
    text-align: center;
    margin-bottom: 25px;
}

.section-title {
    font-size: 24px;
    font-weight: 700;
    color: #2d3748;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    word-wrap: break-word; /* 防止文字溢出 */
}

.section-subtitle {
    color: #718096;
    font-size: 16px;
    margin: 0;
    font-weight: 500;
    word-wrap: break-word; /* 防止文字溢出 */
}

/* 按鈅容器 */
.category-buttons-wrapper {
    position: relative;
    width: 100%;
    overflow: visible; /* 改為 visible 讓懸停效果不被截斷 */
    padding: 10px 0; /* 增加上下 padding 為懸停效果留出空間 */
}

#categoryButtons {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
    margin-bottom: 25px;
    margin-top: 5px; /* 新增：向下移動 5px */
    width: 100%;
    box-sizing: border-box;
    padding: 0 10px; /* 增加左右 padding */
}

/* 分類按鈕基本樣式 */
.category-btn {
    position: relative;
    padding: 16px 24px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 50px;
    border: none;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-transform: none;
    letter-spacing: 0.5px;
    min-height: 52px;
    overflow: hidden;
    backdrop-filter: blur(10px);
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    white-space: nowrap; /* 防止文字換行 */
    flex-shrink: 0; /* 防止按鈕被壓縮 */
}

/* 按鈕點擊時的波紋效果 */
.category-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255,255,255,0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s ease-out, height 0.6s ease-out;
}

.category-btn:active::after {
    width: 300px;
    height: 300px;
}

/* 按鈕發光效果 */
.btn-glow {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s;
}

.category-btn:hover .btn-glow {
    left: 100%;
}

/* 不同分類按鈕漸層配色 */
.gradient-all {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.gradient-text {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    box-shadow: 0 8px 25px rgba(79, 172, 254, 0.3);
}

.gradient-image {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    box-shadow: 0 8px 25px rgba(67, 233, 123, 0.3);
}

.gradient-code {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    box-shadow: 0 8px 25px rgba(250, 112, 154, 0.3);
}

.gradient-productivity {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    color: #333 !important;
    text-shadow: none;
    box-shadow: 0 8px 25px rgba(168, 237, 234, 0.3);
}

.gradient-design {
    background: linear-gradient(135deg, #d299c2 0%, #fef9d7 100%);
    color: #333 !important;
    text-shadow: none;
    box-shadow: 0 8px 25px rgba(210, 153, 194, 0.3);
}

.gradient-writing {
    background: linear-gradient(135deg, #89f7fe 0%, #66a6ff 100%);
    box-shadow: 0 8px 25px rgba(137, 247, 254, 0.3);
}

.gradient-translate {
    background: linear-gradient(135deg, #fdbb2d 0%, #22c1c3 100%);
    box-shadow: 0 8px 25px rgba(253, 187, 45, 0.3);
}

.gradient-video {
    background: linear-gradient(135deg, #ee9ca7 0%, #ffdde1 100%);
    color: #333 !important;
    text-shadow: none;
    box-shadow: 0 8px 25px rgba(238, 156, 167, 0.3);
}

.gradient-content {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    color: #333 !important;
    text-shadow: none;
    box-shadow: 0 8px 25px rgba(255, 236, 210, 0.3);
}

.gradient-presentation {
    background: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%);
    box-shadow: 0 8px 25px rgba(161, 140, 209, 0.3);
}

/* 分類按鈕滑鼠懸停效果 */
.category-btn:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
}

/* 啟動狀態按鈕 */
.category-btn.active {
    transform: translateY(-3px) scale(1.08);
    box-shadow: 0 20px 40px rgba(0,0,0,0.25);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 20px 40px rgba(0,0,0,0.25); }
    50% { box-shadow: 0 25px 50px rgba(0,0,0,0.35); }
    100% { box-shadow: 0 20px 40px rgba(0,0,0,0.25); }
}

/* 按鈕點擊效果 */
.category-btn:active {
    transform: translateY(-1px) scale(1.02);
    transition: all 0.1s;
}

/* 統計信息區域 */
.category-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    flex-wrap: wrap; /* 允許換行 */
    width: 100%;
    box-sizing: border-box;
}

.stats-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #4a5568;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 15px;
    transition: all 0.3s ease;
    white-space: nowrap; /* 防止文字換行 */
    flex-shrink: 0; /* 防止被壓縮 */
}

.stats-item:hover {
    background: rgba(255, 255, 255, 0.8);
    transform: translateY(-2px);
}

/* 結果統計區域動畫 */
.row.mb-3 {
    transition: all 0.3s ease;
}

/* 工具容器過渡動畫 */
#toolsContainer {
    transition: all 0.3s ease;
    width: 100%;
    overflow: hidden; /* 防止內容溢出 */
}

/* 工具卡片樣式 */
.tool-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    /* 確保卡片遵循 Bootstrap 網格系統 */
    flex: 0 0 auto;
}

.tool-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}

.card {
    border-radius: 15px;
    overflow: hidden;
    border: none;
    box-shadow: 0 8px 30px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 100%;
    transition: all 0.3s ease;
    height: 100%; /* 確保所有卡片高度一致 */
}

/* 確保網格系統正常工作 - 重要！ */
#toolsContainer {
    display: flex;
    flex-wrap: wrap;
    margin-right: -12px;
    margin-left: -12px;
}

/* 強制設定 Bootstrap 網格類別 */
.tool-card.col-lg-4 {
    flex: 0 0 33.333333% !important;
    max-width: 33.333333% !important;
    padding-right: 12px !important;
    padding-left: 12px !important;
}

.tool-card.col-md-6 {
    flex: 0 0 50% !important;
    max-width: 50% !important;
    padding-right: 12px !important;
    padding-left: 12px !important;
}

.tool-card.col-sm-12 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    padding-right: 12px !important;
    padding-left: 12px !important;
}

/* 響應式斷點修正 */
@media (min-width: 992px) {
    .tool-card.col-lg-4 {
        flex: 0 0 33.333333% !important;
        max-width: 33.333333% !important;
    }
}

@media (min-width: 768px) and (max-width: 991.98px) {
    .tool-card.col-md-6 {
        flex: 0 0 50% !important;
        max-width: 50% !important;
    }
}

@media (max-width: 767.98px) {
    .tool-card.col-sm-12 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }
}

/* 清單檢視模式 - 卡片水平排列 */
.list-view .tool-card .card {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    min-height: 120px;  
    max-height: 200px;
}

.list-view .tool-card.col-12 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
}

.list-view .tool-card .card-header {
    flex: 0 0 250px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.list-view .tool-card .card-body {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.list-view .tool-card .card-footer {
    flex: 0 0 auto;
    padding: 20px;
    display: flex;
    align-items: center;
}

/* 清單檢視模式 - 徽章位置調整 */
.list-view .tool-card .card-badges-container {
    position: absolute !important;
    top: 10px !important;
    right: 10px !important;
    z-index: 15 !important;
    display: flex !important;
    flex-direction: row !important; /* 保持水平排列 */
    gap: 5px !important;
    align-items: flex-start !important;
}

/* 清單檢視模式 - 內容調整 */
.list-view .tool-card .card-title {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.list-view .tool-card .card-text {
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.list-view .tool-card .badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
}

/* 清單檢視響應式調整 */
@media (max-width: 768px) {
    .list-view .tool-card .card {
        flex-direction: column;
        min-height: auto;
        max-height: none;
    }
    
    .list-view .tool-card .card-header,
    .list-view .tool-card .card-body,
    .list-view .tool-card .card-footer {
        flex: none;
        padding: 15px;
    }
    
    .list-view .tool-card .card-badges-container {
        flex-direction: row !important; /* 保持水平排列，不改為垂直 */
        gap: 4px !important; /* 減少間距以適應小螢幕 */
    }
}

/* 卡片徽章容器 - 確保正確定位在右上角 */
.card-badges-container {
    position: absolute !important;
    top: 10px !important;
    right: 10px !important;
    z-index: 15 !important; /* 提高z-index確保在最上層 */
    display: flex !important;
    flex-direction: row !important; /* 水平排列 */
    gap: 5px !important;
    align-items: flex-start !important;
    pointer-events: none; /* 避免阻擋卡片點擊 */
}

/* 確保卡片有正確的相對定位 */
.card.position-relative {
    position: relative !important;
}

.tool-card .card {
    position: relative !important;
}

/* 徽章樣式 */
.badge-popular,
.badge-pricing {
    font-size: 11px !important;
    padding: 4px 8px !important;
    border-radius: 12px !important;
    font-weight: 600 !important;
    white-space: nowrap !important; /* 防止換行 */
    flex-shrink: 0 !important; /* 防止壓縮 */
    pointer-events: auto; /* 徽章本身可以互動 */
    box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important; /* 添加陰影增加可見性 */
}

/* 熱門徽章特殊樣式 */
.badge-popular {
    background: #ffc107 !important;
    color: #000 !important;
    border: 1px solid rgba(0,0,0,0.1) !important;
}

/* 定價徽章樣式 */
.badge-pricing {
    border: 1px solid rgba(255,255,255,0.2) !important;
}

.badge-pricing.bg-success {
    background: #198754 !important;
    color: white !important;
}

.badge-pricing.bg-info {
    background: #0dcaf0 !important;
    color: #000 !important;
}

/* 小螢幕徽章調整 */
@media (max-width: 576px) {
    .card-badges-container {
        top: 8px !important;
        right: 8px !important;
        gap: 3px !important; /* 進一步減少間距 */
    }
    
    .badge-popular,
    .badge-pricing {
        font-size: 10px !important;
        padding: 3px 6px !important;
    }
}

/* 搜尋區域樣式優化 */
.search-controls {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
}

.search-controls:hover {
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.search-controls .form-label {
    color: #495057;
    font-weight: 600;
    margin-bottom: 12px;
    font-size: 16px;
}

.search-controls .btn {
    min-height: 48px;
    font-weight: 600;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.search-controls .btn-outline-secondary {
    border-color: #dee2e6;
    color: #6c757d;
}

.search-controls .btn-outline-secondary:hover {
    background-color: #e9ecef;
    border-color: #adb5bd;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0,0,0,0.1);
}

.search-controls .input-group {
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.search-controls .input-group:focus-within {
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
    transform: translateY(-1px);
}

.search-controls .input-group-text {
    background: #fff;
    border-color: #dee2e6;
    color: #667eea;
    transition: all 0.3s ease;
}

.search-controls .input-group:focus-within .input-group-text {
    color: #667eea;
    border-color: #667eea;
}

.search-controls .form-control {
    border-color: #dee2e6;
    padding: 12px 16px;
    font-size: 16px;
    transition: all 0.3s ease;
}

.search-controls .form-control:focus {
    border-color: #667eea;
    box-shadow: none; /* 移除默認陰影，使用父容器的陰影 */
}

.search-controls .form-control::placeholder {
    color: #adb5bd;
    transition: color 0.3s ease;
}

.search-controls .form-control:focus::placeholder {
    color: #dee2e6;
}

/* 即時搜尋提示樣式 */
#searchHelp {
    color: #6c757d;
    font-size: 13px;
    margin-left: 8px;
}

/* 響應式搜尋區域 */
@media (max-width: 768px) {
    .search-controls {
        padding: 15px;
        border-radius: 12px;
    }
    
    .search-controls .row.g-2 {
        gap: 10px;
    }
    
    .search-controls .col-auto {
        width: 100%;
        margin-top: 10px;
    }
    
    .search-controls .btn {
        width: 100%;
        min-height: 44px;
    }
}

@media (max-width: 576px) {
    .search-controls {
        padding: 12px;
        margin: 0;
        border-radius: 10px;
    }
    
    .search-controls .btn {
        font-size: 14px;
        min-height: 42px;
    }
    
    .search-controls .form-control {
        font-size: 14px;
        padding: 10px 14px;
    }
    
    .search-controls .form-label {
        font-size: 14px;
        margin-bottom: 8px;
    }
}

/* 回到頂部按鈕 */
.scroll-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50%;
    display: none;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
    z-index: 1000;
    font-size: 20px;
}

.scroll-to-top:hover {
    transform: translateY(-5px) scale(1.1);
    box-shadow: 0 15px 35px rgba(102, 126, 234, 0.4);
}

.scroll-to-top.show {
    display: flex;
}

/* 淡入動畫 - 通用 */
.fade-in {
    animation: fadeInSlideUp 0.6s ease-out forwards;
    opacity: 0;
    transform: translateY(30px);
}

@keyframes fadeInSlideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 載入動畫 */
.spinner-border {
    color: #667eea !important;
}

/* 結果統計區域 */
#resultsCount {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white;
    padding: 8px 16px;
    border-radius: 25px;
    font-weight: 700;
    font-size: 16px;
    transition: all 0.3s ease;
}

/* 結果數量變化動畫 */
#resultsCount.updating {
    animation: countUpdate 0.3s ease-in-out;
}

@keyframes countUpdate {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%); }
    100% { transform: scale(1); }
}

/* 檢視模式按鈕 */
.btn-check:checked + .btn-outline-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

/* 過濾時的載入狀態 */
.filtering {
    opacity: 0.7;
    pointer-events: none;
}

.filtering .tool-card {
    transform: scale(0.95);
    opacity: 0.5;
}

/* 無結果時的動畫 */
.no-results {
    animation: shakeNo 0.5s ease-in-out;
}

@keyframes shakeNo {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* 迷你分類按鈕樣式 */
.btn-group-mini {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    overflow: hidden; /* 防止溢出 */
}

.mini-category-btn {
    border-radius: 20px !important;
    padding: 6px 12px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    transition: all 0.2s ease !important;
    border: 1px solid #dee2e6 !important;
    white-space: nowrap;
    display: flex;
    align-items: center;
    min-height: 32px;
    flex-shrink: 0; /* 防止被壓縮 */
}

.mini-category-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.mini-category-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    border-color: #667eea !important;
    color: white !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.mini-category-btn i {
    font-size: 11px;
}

/* 響應式設計 - 迷你按鈕 */
@media (max-width: 992px) {
    .mini-category-btn {
        padding: 5px 10px !important;
        font-size: 11px !important;
        min-height: 28px;
    }
    
    .mini-category-btn i {
        font-size: 10px;
    }
}

@media (max-width: 768px) {
    .btn-group-mini {
        gap: 3px;
    }
    
    .mini-category-btn {
        padding: 4px 8px !important;
        font-size: 10px !important;
        min-height: 26px;
    }
}

@media (max-width: 576px) {
    .btn-group-mini {
        justify-content: center;
        width: 100%;
        margin-top: 10px;
    }
    
    .mini-category-btn {
        flex: 1;
        max-width: 45px;
        justify-content: center;
        padding: 4px 6px !important;
    }
}

/* 結果區域的響應式配置 */
@media (max-width: 576px) {
    .row.mb-3 .col-12 > .d-flex {
        flex-direction: column;
        gap: 15px;
        align-items: center;
        width: 100%;
    }
    
    .row.mb-3 h2 {
        text-align: center;
        font-size: 1.2rem;
    }
}

/* 防止所有元素造成水平捲軸 */
* {
    box-sizing: border-box;
}

/* 確保所有 row 不會造成水平捲軸 */
.row {
    margin-left: 0;
    margin-right: 0;
    width: 100%;
}

.row > * {
    padding-left: 12px;
    padding-right: 12px;
}

/* 確保所有容器不會超出視窗寬度 */
.container, .container-fluid, .container-sm, .container-md, .container-lg, .container-xl, .container-xxl {
    max-width: 100%;
    overflow-x: hidden;
}