/**
 * Comparison Table for Elementor - Frontend CSS
 */

/* ==========================================================================
   基礎樣式
   ========================================================================== */

.ctfe_comparison_button_wrapper,
.ctfe_comparison_table_wrapper,
.ctfe_comparison_number_wrapper {
    box-sizing: border-box;
}

/* 隱藏類別 */
.ctfe_hidden {
    display: none !important;
}

.ctfe_comparison_button_wrapper *,
.ctfe_comparison_table_wrapper *,
.ctfe_comparison_number_wrapper * {
    box-sizing: inherit;
}

/* ==========================================================================
   比較按鈕樣式
   ========================================================================== */

.ctfe_comparison_button_wrapper {
    display: flex;
    position: relative;
}

.ctfe_comparison_button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    background-color: #007cba;
    color: #ffffff;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.ctfe_comparison_button:hover {
    background-color: #005a87;
    transform: translateY(-1px);
}

.ctfe_comparison_button:active {
    transform: translateY(0);
}

.ctfe_comparison_button.ctfe_loading {
    opacity: 0.6;
    pointer-events: none;
}

.ctfe_comparison_button.ctfe_loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: ctfe_spin 0.8s linear infinite;
}

@keyframes ctfe_spin {
    to {
        transform: rotate(360deg);
    }
}

.ctfe_comparison_button .ctfe_button_icon {
    display: inline-flex;
    align-items: center;
    font-size: 1em;
}

.ctfe_comparison_button .ctfe_button_icon svg {
    width: 1em;
    height: 1em;
    fill: currentColor;
}

/* 移除比較按鈕樣式 */
.ctfe_comparison_button.ctfe_remove_button {
    background-color: #dc3545;
}

.ctfe_comparison_button.ctfe_remove_button:hover {
    background-color: #c82333;
}

/* 觀看比較按鈕樣式 */
.ctfe_view_comparison_button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    margin-left: 8px;
    border: 2px solid #007cba;
    border-radius: 4px;
    background-color: transparent;
    color: #007cba;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    transition: all 0.3s ease;
}

.ctfe_view_comparison_button:hover {
    background-color: #007cba;
    color: #ffffff;
    text-decoration: none;
}

.ctfe_view_comparison_button .ctfe_button_icon svg {
    width: 1em;
    height: 1em;
    fill: currentColor;
}

/* ==========================================================================
   比較表格樣式
   ========================================================================== */

.ctfe_comparison_table_wrapper {
    margin: 20px 0;
    width: 100%;
}

.ctfe_comparison_table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.ctfe_comparison_table th,
.ctfe_comparison_table td {
    padding: 12px 15px;
    text-align: center;
    vertical-align: middle;
    border-bottom: 1px solid #e9ecef;
    border-right: 1px solid #e9ecef;
}

.ctfe_comparison_table th:last-child,
.ctfe_comparison_table td:last-child {
    border-right: none;
}

.ctfe_comparison_table tbody tr:last-child th,
.ctfe_comparison_table tbody tr:last-child td {
    border-bottom: none;
}

/* 表格標題樣式 */
.ctfe_comparison_table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #495057;
    position: relative;
}

.ctfe_comparison_table.ctfe_striped tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

/* 欄位標籤樣式 */
.ctfe_comparison_table .ctfe_field_label {
    background-color: #e9ecef;
    font-weight: 600;
    text-align: left;
    width: 200px;
    min-width: 150px;
}

/* 項目縮圖樣式 */
.ctfe_item_thumbnail_container {
    margin-bottom: 8px;
}

.ctfe_item_thumbnail {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #ddd;
}

/* 項目標題樣式 */
.ctfe_item_title {
    font-weight: 600;
    margin-bottom: 8px;
}

.ctfe_item_title a {
    color: #007cba;
    text-decoration: none;
}

.ctfe_item_title a:hover {
    text-decoration: underline;
}

/* 欄位值樣式 */
.ctfe_field_value img.ctfe_field_image {
    max-width: 50px;
    max-height: 50px;
    object-fit: cover;
    border-radius: 3px;
    margin-right: 5px;
}

/* 調試樣式 */
.ctfe_debug_value {
    background-color: #fff3cd;
    color: #856404;
    padding: 5px;
    border-radius: 3px;
    font-size: 11px;
    border: 1px solid #ffeaa7;
}

.ctfe_debug_invalid_id {
    background-color: #f8d7da;
    color: #721c24;
    padding: 3px 6px;
    border-radius: 3px;
    font-size: 11px;
    border: 1px solid #f5c6cb;
}

.ctfe_field_value a {
    color: #007cba;
    text-decoration: none;
}

.ctfe_field_value a:hover {
    text-decoration: underline;
}

/* 移除按鈕樣式 */
.ctfe_remove_item_button {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background-color: #dc3545;
    color: #ffffff;
    font-size: 12px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.ctfe_remove_item_button:hover {
    background-color: #c82333;
    transform: scale(1.06);
}

/* 空白訊息樣式 */
.ctfe_empty_message {
    text-align: center;
    padding: 40px 20px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    color: #6c757d;
    font-size: 16px;
}

.ctfe_empty_message p {
    margin: 0;
    font-style: italic;
}

/* ==========================================================================
   比較數量按鈕樣式
   ========================================================================== */

.ctfe_comparison_number_wrapper {
    position: relative;
    display: inline-block;
}

.ctfe_comparison_number_button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    background-color: #007cba;
    color: #ffffff;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    transition: all 0.3s ease;
}

.ctfe_comparison_number_button:hover {
    background-color: #005a87;
    text-decoration: none;
    color: #ffffff;
    transform: translateY(-1px);
}

.ctfe_comparison_number_button .ctfe_icon_left,
.ctfe_comparison_number_button .ctfe_icon_right {
    display: inline-flex;
    align-items: center;
    font-size: 1em;
}

.ctfe_comparison_number_button .ctfe_icon_left svg,
.ctfe_comparison_number_button .ctfe_icon_right svg {
    width: 1em;
    height: 1em;
    fill: currentColor;
}

/* 數量徽章樣式 */
.ctfe_comparison_badge {
    position: absolute;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 50%;
    background-color: #dc3545;
    color: #ffffff;
    font-size: 12px;
    font-weight: bold;
    line-height: 20px;
    text-align: center;
    z-index: 2;
}

/* 徽章位置 */
.ctfe_comparison_number_wrapper.ctfe_badge_top-left .ctfe_comparison_badge {
    top: -5px;
    left: -5px;
}

.ctfe_comparison_number_wrapper.ctfe_badge_top-right .ctfe_comparison_badge {
    top: -5px;
    right: -5px;
}

.ctfe_comparison_number_wrapper.ctfe_badge_bottom-left .ctfe_comparison_badge {
    bottom: -5px;
    left: -5px;
}

.ctfe_comparison_number_wrapper.ctfe_badge_bottom-right .ctfe_comparison_badge {
    bottom: -5px;
    right: -5px;
}

/* ==========================================================================
   訊息提示樣式
   ========================================================================== */

.ctfe_message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 20px;
    border-radius: 6px;
    color: #ffffff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: ctfe_slideDown 0.3s ease-out;
}

@keyframes ctfe_slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.ctfe_message_success {
    background-color: #28a745;
}

.ctfe_message_error {
    background-color: #dc3545;
}

.ctfe_message_info {
    background-color: #17a2b8;
}

/* ==========================================================================
   響應式設計
   ========================================================================== */

/* 移動端樣式 */
.ctfe_comparison_table_wrapper.ctfe_mobile_scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.ctfe_comparison_table_wrapper.ctfe_mobile_scroll .ctfe_comparison_table {
    min-width: 600px;
    white-space: nowrap;
}

.ctfe_comparison_table_wrapper.ctfe_mobile_scroll .ctfe_comparison_table th,
.ctfe_comparison_table_wrapper.ctfe_mobile_scroll .ctfe_comparison_table td {
    white-space: nowrap;
    min-width: 120px;
}

.ctfe_comparison_table_wrapper.ctfe_mobile_scroll .ctfe_field_label {
    min-width: 150px;
    white-space: normal;
}

/* 平板樣式 */
@media (max-width: 768px) {
    .ctfe_comparison_button,
    .ctfe_comparison_number_button,
    .ctfe_view_comparison_button {
        padding: 10px 20px;
        font-size: 13px;
    }

    .ctfe_comparison_table th,
    .ctfe_comparison_table td {
        padding: 8px 12px;
        font-size: 13px;
    }

    .ctfe_item_thumbnail {
        width: 40px;
        height: 40px;
    }

    .ctfe_comparison_badge {
        font-size: 11px;
        min-width: 18px;
        height: 18px;
        line-height: 18px;
    }
}

/* 手機樣式 */
@media (max-width: 480px) {
    .ctfe_comparison_button_wrapper {
        display: block;
        text-align: center;
        margin: 10px 0;
    }

    .ctfe_comparison_button,
    .ctfe_comparison_number_button {
        width: 100%;
        max-width: 280px;
        padding: 12px 16px;
    }

    .ctfe_view_comparison_button {
        width: 100%;
        max-width: 200px;
        margin-left: 0;
        margin-top: 8px;
    }

    .ctfe_comparison_table th,
    .ctfe_comparison_table td {
        padding: 6px 8px;
        font-size: 12px;
    }

    .ctfe_field_label {
        width: auto;
        min-width: 100px;
    }

    .ctfe_item_thumbnail {
        width: 30px;
        height: 30px;
    }

    .ctfe_remove_item_button {
        width: 24px;
        height: 24px;
        top: 2px;
        right: 2px;
        font-size: 14px;
    }

    .ctfe_message {
        left: 10px;
        right: 10px;
        transform: none;
        font-size: 13px;
    }
}

/* ==========================================================================
   載入動畫
   ========================================================================== */

.ctfe_loading {
    color: #6c757d;
    font-style: italic;
}

.ctfe_loading::after {
    content: "";
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-left: 8px;
    border: 2px solid #dee2e6;
    border-top-color: #007cba;
    border-radius: 50%;
    animation: ctfe_spin 0.8s linear infinite;
}

/* ==========================================================================
   預覽模式樣式
   ========================================================================== */

.ctfe_comparison_button_preview {
    padding: 20px;
    background-color: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 6px;
    text-align: center;
    color: #6c757d;
    font-style: italic;
}

/* ==========================================================================
   可訪問性增強
   ========================================================================== */

.ctfe_comparison_button:focus,
.ctfe_comparison_number_button:focus,
.ctfe_view_comparison_button:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

.ctfe_remove_item_button:focus {
    outline: 2px solid #dc3545;
    outline-offset: 2px;
}

/* 高對比模式支援 */
@media (prefers-contrast: high) {
    .ctfe_comparison_table {
        border: 2px solid #000;
    }

    .ctfe_comparison_table th,
    .ctfe_comparison_table td {
        border: 1px solid #000;
    }

    .ctfe_comparison_button,
    .ctfe_comparison_number_button {
        border: 2px solid #000;
    }
}

/* 動畫減少模式支援 */
@media (prefers-reduced-motion: reduce) {
    .ctfe_comparison_button,
    .ctfe_comparison_number_button,
    .ctfe_view_comparison_button,
    .ctfe_remove_item_button,
    .ctfe_message {
        transition: none;
        animation: none;
    }
    
    .ctfe_comparison_button:hover,
    .ctfe_comparison_number_button:hover {
        transform: none;
    }
}