/* ========================================
   前台互動功能 CSS
   ======================================== */

/* 免費諮詢按鈕 (最下面) - 從右側滑入 */
.consult-button {
    position: fixed;
    bottom: 30px;
    right: -80px;
    width: 65px;
    height: 65px;
    background-color: #c62828;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(198, 40, 40, 0.3);
}

.consult-button.show {
    opacity: 1;
    right: 30px;
}

.consult-button:hover {
    background-color: #d32f2f;
    color: white;
    transform: translateY(-5px) scale(1.1);
    box-shadow: 0 6px 16px rgba(198, 40, 40, 0.4);
}

.consult-button i {
    font-size: 1.5rem;
}

/* 返回頂部按鈕 (中間) - 從下方彈入 */
.back-to-top {
    position: fixed;
    bottom: -80px;
    right: 30px;
    width: 65px;
    height: 65px;
    background-color: #c62828;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    transition-delay: 0.1s;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(198, 40, 40, 0.3);
}

.back-to-top:hover {
    background-color: #d32f2f;
    transform: translateY(-5px) scale(1.1);
    box-shadow: 0 6px 16px rgba(198, 40, 40, 0.4);
}

.back-to-top.show {
    opacity: 1;
    bottom: 110px;
}

.back-to-top i {
    font-size: 1.5rem;
}

/* LINE 按鈕 (最上面) - 從上方掉落 */
.line-button {
    position: fixed;
    bottom: 300px;
    right: 30px;
    width: 65px;
    height: 65px;
    background-color: transparent;
    border: none;
    cursor: pointer;
    opacity: 0;
    transition: all 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    transition-delay: 0.2s;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.line-button.show {
    opacity: 1;
    bottom: 190px;
}

.line-button:hover {
    transform: translateY(-5px);
}

.line-button img {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.line-button:hover img {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

/* 導航列滾動效果 */
.navbar {
    transition: all 0.3s ease;
}

.navbar-scrolled {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    background-color: rgba(255, 255, 255, 0.98) !important;
}

/* 圖片 Lazy Loading */
img[data-src] {
    opacity: 0;
    transition: opacity 0.3s ease;
}

img[data-src].loaded {
    opacity: 1;
}

/* 淡入動畫 */
.fade-in {
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 載入動畫 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-overlay .spinner-border {
    width: 3rem;
    height: 3rem;
}

/* 提示訊息 */
.toast-message {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease;
    z-index: 9999;
    max-width: 350px;
}

.toast-message.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-message.toast-success {
    border-left: 4px solid #28a745;
}

.toast-message.toast-error {
    border-left: 4px solid #dc3545;
}

.toast-message.toast-warning {
    border-left: 4px solid #ffc107;
}

.toast-message.toast-info {
    border-left: 4px solid #17a2b8;
}

/* 統計數字動畫 */
.stat-number {
    font-size: 3rem;
    font-weight: 700;
    color: #c62828;
    transition: all 0.3s ease;
}

.stat-label {
    font-size: 1.1rem;
    color: #6c757d;
    margin-top: 0.5rem;
}

/* 作品集篩選按鈕 */
.filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 2rem;
    justify-content: center;
}

.filter-buttons .btn {
    border-radius: 25px;
    padding: 0.5rem 1.5rem;
    transition: all 0.3s ease;
}

.filter-buttons .btn.active {
    background-color: #c62828;
    color: white;
    border-color: #c62828;
}

.filter-buttons .btn:not(.active) {
    background-color: white;
    color: #6c757d;
    border-color: #dee2e6;
}

.filter-buttons .btn:not(.active):hover {
    background-color: #f8f9fa;
    border-color: #c62828;
    color: #c62828;
}

/* 卡片 hover 效果 */
.hover-lift {
    transition: all 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-10px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

/* 服務卡片圖示翻轉效果 */
.service-icon-wrapper {
    perspective: 1000px;
    display: inline-block;
    width: 80px;
    height: 80px;
    margin: 0 auto;
}

.service-icon {
    transition: transform 0.6s ease-in-out !important;
    transform-style: preserve-3d;
    display: block;
    will-change: transform;
    backface-visibility: hidden;
}

/* 桌面版翻轉效果 */
@media (hover: hover) and (pointer: fine) {
    .service-card:hover .service-icon {
        transform: rotateY(360deg) !important;
    }
}

/* 觸控裝置點擊效果 */
@media (hover: none) and (pointer: coarse) {
    .service-card:active .service-icon {
        transform: rotateY(180deg) !important;
    }
}

/* 圖片 hover 效果 */
.img-hover-zoom {
    overflow: hidden;
}

.img-hover-zoom img {
    transition: transform 0.5s ease;
}

.img-hover-zoom:hover img {
    transform: scale(1.1);
}

/* 表單驗證樣式 */
.was-validated .form-control:valid,
.form-control.is-valid {
    border-color: #28a745;
    padding-right: calc(1.5em + 0.75rem);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%2328a745' d='M2.3 6.73L.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.was-validated .form-control:invalid,
.form-control.is-invalid {
    border-color: #dc3545;
    padding-right: calc(1.5em + 0.75rem);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

/* 輪播指示點樣式 */
.carousel-indicators [data-bs-target] {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin: 0 5px;
    background-color: rgba(255, 255, 255, 0.5);
    border: 2px solid white;
    transition: all 0.3s ease;
}

.carousel-indicators .active {
    background-color: white;
    width: 40px;
    border-radius: 6px;
}

/* 輪播控制按鈕 */
.carousel-control-prev,
.carousel-control-next {
    width: 50px;
    height: 50px;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(198, 40, 40, 0.8);
    border-radius: 50%;
    opacity: 0;
    transition: all 0.3s ease;
}

.carousel:hover .carousel-control-prev,
.carousel:hover .carousel-control-next {
    opacity: 1;
}

.carousel-control-prev:hover,
.carousel-control-next:hover {
    background-color: rgba(198, 40, 40, 1);
}

.carousel-control-prev {
    left: 20px;
}

.carousel-control-next {
    right: 20px;
}

/* 平滑滾動 */
html {
    scroll-behavior: smooth;
}

/* 滾動條樣式 (Webkit) */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c62828;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #d32f2f;
}

/* 選取文字顏色 */
::selection {
    background-color: #c62828;
    color: white;
}

::-moz-selection {
    background-color: #c62828;
    color: white;
}

/* 焦點樣式 */
:focus {
    outline: 2px solid #c62828;
    outline-offset: 2px;
}

/* 跳過連結 (無障礙) */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #c62828;
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 100;
}

.skip-link:focus {
    top: 0;
}

/* 分頁樣式 - 紅色主題 */
.pagination .page-link {
    color: #c62828;
    border-color: #dee2e6;
}

.pagination .page-link:hover {
    color: #d32f2f;
    background-color: #f8f9fa;
    border-color: #c62828;
}

.pagination .page-link:focus {
    color: #c62828;
    background-color: #f8f9fa;
    border-color: #c62828;
    box-shadow: 0 0 0 0.2rem rgba(198, 40, 40, 0.25);
}

.pagination .page-item.active .page-link {
    background-color: #c62828;
    border-color: #c62828;
    color: white;
}

.pagination .page-item.disabled .page-link {
    color: #6c757d;
    background-color: white;
    border-color: #dee2e6;
}

/* 響應式調整 */
@media (max-width: 767px) {
    .consult-button {
        width: 50px;
        height: 50px;
        bottom: 20px;
    }
    
    .consult-button.show {
        right: 20px;
    }
    
    .consult-button i {
        font-size: 1.2rem;
    }
    
    .back-to-top {
        width: 50px;
        height: 50px;
        right: 20px;
    }
    
    .back-to-top.show {
        bottom: 85px;
    }
    
    .back-to-top i {
        font-size: 1.2rem;
    }
    
    .line-button {
        width: 50px;
        height: 50px;
        right: 20px;
    }
    
    .line-button.show {
        bottom: 150px;
    }
    
    .line-button img {
        width: 50px;
        height: 50px;
    }
    
    .toast-message {
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .stat-number {
        font-size: 2rem;
    }
    
    .carousel-control-prev,
    .carousel-control-next {
        width: 40px;
        height: 40px;
    }
    
    .carousel-control-prev {
        left: 10px;
    }
    
    .carousel-control-next {
        right: 10px;
    }
}

/* 列印樣式 */
@media print {
    .back-to-top,
    .line-button,
    .consult-button,
    .toast-message,
    .loading-overlay {
        display: none !important;
    }
}

/* ========================================
   打字機效果
   ======================================== */
.typewriter-text {
    overflow: hidden;
    white-space: nowrap;
    border-right: 3px solid #c62828;
    animation: typing 2s steps(15, end), blink-caret 0.75s step-end infinite;
    display: inline-block;
}

.typewriter-text.typed {
    border-right: none;
    animation: none;
}

@keyframes typing {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes blink-caret {
    from, to { border-color: transparent; }
    50% { border-color: #c62828; }
}

/* ========================================
   數字計數動畫
   ======================================== */
.count-up {
    font-size: 3rem;
    font-weight: 700;
    color: #c62828;
    display: inline-block;
}

.count-up-wrapper {
    text-align: center;
    padding: 1.5rem;
}

.count-up-label {
    font-size: 1rem;
    color: #6c757d;
    margin-top: 0.5rem;
}

/* ========================================
   滾動淡入動畫
   ======================================== */
.scroll-fade-in {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.scroll-fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

.scroll-fade-in-left {
    opacity: 0;
    transform: translateX(-50px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.scroll-fade-in-left.visible {
    opacity: 1;
    transform: translateX(0);
}

.scroll-fade-in-right {
    opacity: 0;
    transform: translateX(50px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.scroll-fade-in-right.visible {
    opacity: 1;
    transform: translateX(0);
}

/* ========================================
   脈動效果 (CTA 按鈕)
   ======================================== */
.pulse-animation {
    animation: pulse 1.2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 4px 12px rgba(198, 40, 40, 0.3), 0 0 0 0 rgba(198, 40, 40, 0.6);
    }
    50% {
        box-shadow: 0 4px 12px rgba(198, 40, 40, 0.3), 0 0 0 25px rgba(198, 40, 40, 0);
    }
    100% {
        box-shadow: 0 4px 12px rgba(198, 40, 40, 0.3), 0 0 0 0 rgba(198, 40, 40, 0);
    }
}

/* ========================================
   浮動效果
   ======================================== */
.hover-float {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-float:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

/* ========================================
   漸層背景
   ======================================== */
.bg-gradient-primary {
    background: linear-gradient(135deg, #c62828 0%, #b71c1c 100%);
}

.hero-tagline-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.5;
}

/* ========================================
   卡片進場動畫
   ======================================== */
.card-animate {
    opacity: 0;
    transform: translateY(20px);
}

.card-animate.animate-in {
    animation: cardFadeIn 0.5s ease forwards;
}

@keyframes cardFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
