/* static/css/homepage.css - 首頁專用樣式 */

/* ===== Hero Section 樣式 ===== */
.hero-section {
  padding: var(--spacing-xxl) 0;
  background: linear-gradient(135deg, var(--warm-bg) 0%, var(--warm-light) 100%);
  min-height: 60vh;
  display: flex;
  align-items: center;
}

.hero-text h1 {
  font-size: var(--font-size-4xl);
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: var(--spacing-md);
  line-height: 1.2;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.hero-text .text-warning {
  background: linear-gradient(45deg, #ffc107, #ff8c00);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-img {
  max-width: 100%;
  height: auto;
  border-radius: var(--border-radius-lg);
  box-shadow: 0 8px 32px var(--shadow-light);
  transition: transform var(--transition-slow) ease;
}

.hero-img:hover {
  transform: scale(1.05) rotate(2deg);
}

/* ===== 新聞區塊樣式 ===== */
.news-section {
  padding: var(--spacing-xxl) 0;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.news-title {
  font-size: var(--font-size-3xl);
  font-weight: 600;
  margin-bottom: var(--spacing-xl);
  color: var(--text-dark);
  position: relative;
}

.news-title::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 4px;
  background: linear-gradient(90deg, var(--primary-orange), var(--primary-orange-light));
  border-radius: 2px;
}

.news-card {
  width: 200px;
  height: 130px;
  border: 2px dashed var(--news-border);
  border-radius: var(--border-radius-md);
  overflow: hidden;
  background-color: #fff;
  transition: all var(--transition-normal) ease;
  flex-shrink: 0;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  position: relative;
}

.news-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.1) 50%, transparent 70%);
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}

.news-card:hover::before {
  transform: translateX(100%);
}

.news-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 12px 30px rgba(0,0,0,0.15);
  border-color: var(--primary-orange);
  border-style: solid;
}

.news-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-normal) ease;
}

.news-card:hover img {
  transform: scale(1.1);
}

.news-card.more {
  background: linear-gradient(135deg, #f7f0e8 0%, #fff 100%);
  font-weight: bold;
  color: var(--text-dark);
  font-size: var(--font-size-base);
  border-color: var(--primary-orange);
}

.news-card.more:hover {
  background: linear-gradient(135deg, var(--primary-orange-light) 0%, #fff 100%);
  color: var(--primary-orange);
}

.news-scroll-container {
  overflow-x: auto;
  padding: var(--spacing-md) 0;
  scroll-behavior: smooth;
}

.news-scroll-container::-webkit-scrollbar {
  height: 8px;
}

.news-scroll-container::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.news-scroll-container::-webkit-scrollbar-thumb {
  background: linear-gradient(90deg, var(--primary-orange), var(--primary-orange-light));
  border-radius: 10px;
}

.news-scroll-container::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(90deg, var(--primary-orange-hover), var(--primary-orange));
}

/* ===== 分類卡片樣式 ===== */
.category-card {
  background: linear-gradient(135deg, #ffffff 0%, #fafafa 100%);
  border-radius: var(--border-radius-lg);
  box-shadow: 0 4px 20px var(--shadow-light);
  padding: var(--spacing-xl) var(--spacing-md);
  text-align: center;
  height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-normal) ease;
  text-decoration: none;
  color: var(--text-dark);
  border: 1px solid transparent;
  position: relative;
  overflow: hidden;
}

.category-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, transparent, rgba(255,170,0,0.1), transparent);
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}

.category-card:hover::before {
  transform: translateX(100%);
}

.category-card:hover {
  transform: translateY(-12px);
  box-shadow: 0 15px 45px var(--shadow-medium);
  background: linear-gradient(135deg, #fff 0%, var(--warm-card) 100%);
  border-color: var(--primary-orange);
  color: var(--text-dark);
}

.category-icon {
  width: 60px;
  height: 60px;
  margin-bottom: var(--spacing-md);
  transition: transform var(--transition-normal) ease;
  filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.1));
}

.category-card:hover .category-icon {
  transform: scale(1.2) rotate(5deg);
}

.category-text {
  font-size: var(--font-size-lg);
  font-weight: 600;
  transition: color var(--transition-normal) ease;
}

.category-card:hover .category-text {
  color: var(--primary-orange);
}

/* ===== 特色功能區塊 ===== */
.features-highlight {
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
}

.features-highlight .bg-warning {
  background: linear-gradient(135deg, var(--primary-orange-light), rgba(255,193,7,0.1)) !important;
  transition: all var(--transition-normal) ease;
}

.features-highlight .col-lg-4:hover .bg-warning {
  background: linear-gradient(135deg, var(--primary-orange), var(--primary-orange-light)) !important;
  transform: scale(1.1);
}

.features-highlight .col-lg-4:hover .text-warning {
  color: white !important;
}

.features-highlight h4 {
  color: var(--text-dark);
  transition: color var(--transition-normal) ease;
}

.features-highlight .col-lg-4:hover h4 {
  color: var(--primary-orange);
}

/* ===== Call to Action 區塊 ===== */
.cta-section {
  background: linear-gradient(135deg, var(--warm-bg) 0%, var(--warm-light) 100%);
  position: relative;
  overflow: hidden;
}

.cta-section::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,170,0,0.1) 0%, transparent 70%);
  animation: pulse 4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.1); }
}

/* ===== 動畫效果 ===== */
.fade-in-up {
  animation: fadeInUp 0.8s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.bounce-in {
  animation: bounceIn 1s ease-out;
}

@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.slide-in-left {
  animation: slideInLeft 0.8s ease-out;
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-50px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.slide-in-right {
  animation: slideInRight 0.8s ease-out;
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(50px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ===== 載入動畫 ===== */
.section-loading {
  position: relative;
}

.section-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--primary-orange);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ===== 響應式設計 ===== */
@media (max-width: 768px) {
  .hero-section {
    padding: var(--spacing-xl) 0;
    min-height: 50vh;
  }
  
  .hero-text h1 {
    font-size: var(--font-size-3xl);
  }
  
  .news-title {
    font-size: var(--font-size-2xl);
  }
  
  .news-card {
    width: 160px;
    height: 110px;
  }
  
  .category-card {
    height: 150px;
    padding: var(--spacing-lg) var(--spacing-md);
  }
  
  .category-icon {
    width: 45px;
    height: 45px;
  }
  
  .category-text {
    font-size: var(--font-size-base);
  }
  
  .features-highlight .bg-warning {
    width: 60px !important;
    height: 60px !important;
  }
}

@media (max-width: 576px) {
  .hero-section {
    padding: var(--spacing-lg) 0;
  }
  
  .hero-text h1 {
    font-size: var(--font-size-2xl);
    text-align: center;
  }
  
  .hero-text .lead {
    text-align: center;
  }
  
  .hero-text .d-flex {
    justify-content: center;
  }
  
  .news-card {
    width: 140px;
    height: 100px;
  }
  
  .news-title::after {
    width: 60px;
  }
  
  .category-card {
    height: 130px;
  }
  
  .category-icon {
    width: 40px;
    height: 40px;
  }
  
  .category-text {
    font-size: var(--font-size-sm);
  }
}

/* ===== 高對比度模式支援 ===== */
@media (prefers-contrast: high) {
  .news-card,
  .category-card {
    border-width: 3px;
  }
  
  .hero-text h1 {
    text-shadow: none;
  }
  
  .news-title::after {
    height: 6px;
  }
}

/* ===== 深色模式支援（未來擴展用） ===== */
@media (prefers-color-scheme: dark) {
  .hero-section {
    background: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
  }
  
  .news-section {
    background: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
  }
  
  .category-card {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    color: #e2e8f0;
  }
  
  .news-card {
    background-color: #4a5568;
    border-color: #718096;
  }
}

/* ===== 動畫暫停（節能模式） ===== */
@media (prefers-reduced-motion: reduce) {
  .hero-img,
  .news-card,
  .category-card,
  .category-icon {
    transition: none;
  }
  
  .news-card::before,
  .category-card::before,
  .cta-section::before {
    animation: none;
  }
  
  .fade-in-up,
  .bounce-in,
  .slide-in-left,
  .slide-in-right {
    animation: none;
  }
}

/* === AI 客服懸浮元件 === */
#chatbot-button{
  position: fixed;
  right: 20px;
  bottom: 88px;                 /* 預留 88px，避免壓到回到頂部按鈕 */
  width: 56px; height: 56px;
  border-radius: 999px;
  background: #22c55e;
  color: #0b0b0b;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  cursor: pointer;
  z-index: 9999;
}

#chatbot-box{
  position: fixed;
  right: 20px;
  bottom: 160px;                /* 與按鈕垂直錯開 */
  width: 360px; max-width: 92vw;
  height: 520px; max-height: 75vh;
  background: #0f1115; color: #e5e7eb;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
  display: none; flex-direction: column; overflow: hidden;
  z-index: 10000;
  border: 1px solid rgba(255,255,255,.06);
}

#chatbot-header{
  padding: 12px 14px;
  font-weight: 700;
  background: #111827;
  border-bottom: 1px solid #1f2937;
  display: flex; align-items: center; justify-content: space-between;
}
#chatbot-close{ cursor: pointer; opacity: .8; }
#chatbot-close:hover{ opacity: 1; }

#chatbot-messages{
  flex: 1; padding: 12px; overflow: auto;
  scrollbar-width: thin;
}
.cb-bubble {
  padding: 10px 12px;
  border-radius: 12px;
  margin: 8px 0;
  line-height: 1.55;
  word-wrap: break-word;
  white-space: pre-wrap;   /* ⭐ 保留換行與空白 */
}

.cb-user{ background:#2563eb; color:#fff; border-bottom-right-radius:4px; margin-left: 48px; }
.cb-bot{ background:#1f2937; color:#fff; border-bottom-left-radius:4px; margin-right: 48px; }

#chatbot-input{
  display: flex; gap: 8px; padding: 12px; border-top: 1px solid #1f2937; background: #0b0c10;
}
#chatbot-text{
  flex: 1; padding: 10px 12px; border-radius: 10px; border: 1px solid #273042;
  background:#0f172a; color:#e5e7eb; outline: none;
}
#chatbot-send{
  padding: 10px 14px; border-radius: 10px; border: none;
  background:#22c55e; color:#0b0b0b; font-weight: 800; cursor: pointer;
}
#chatbot-send[disabled]{ opacity:.6; cursor: not-allowed; }

/* 手機優化：把元件往上挪，避免壓到系統導覽列 */
@media (max-width: 576px){
  #chatbot-button{ bottom: 96px; right: 14px; }
  #chatbot-box{ width: calc(100vw - 24px); right: 12px; bottom: 168px; height: 60vh; }
}

/* === 內嵌「轉人工客服」按鈕樣式 === */
.cb-inline-btn{
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid #334155;
  border-radius: 6px;
  background: #0f172a;
  color: #e5e7eb;
  font: inherit;
  line-height: 1.2;
  cursor: pointer;
  margin: 0 2px;
  font-size: 0.9em;
}
.cb-inline-btn:hover{
  background: #111827;
  border-color: #475569;
}
.cb-inline-btn:active{
  transform: translateY(1px);
}
