/* style.css */
:root {
  --primary-color: #00eaff;
  --primary-dark: #020c1b;
  --accent-green: #15ff75;
  --accent-red: #ff4d4d;
  --accent-gold: #ffd700;
  --card-bg: rgba(0, 20, 40, 0.8);
  --text-light: #c8d6e5;
  --glow-color: rgba(0, 234, 255, 0.6);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "Exo 2", "Segoe UI", Roboto, Arial, sans-serif;
  color: #fff;
  background: var(--primary-dark);
  -webkit-tap-highlight-color: transparent;
  line-height: 1.6;
  overflow-x: hidden;
}
body {
  position: relative;
  min-height: 100vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
}

/* พื้นหลังสไตล์ไซไฟ - เวอร์ชันแก้ไข */
.scifi-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  background: linear-gradient(125deg, #020c1b 0%, #0a1a30 30%, #0c2342 70%, #051324 100%);
  overflow: hidden;
}

/* เอฟเฟกต์ตาราง */
.grid-lines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    linear-gradient(rgba(0, 234, 255, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 234, 255, 0.1) 1px, transparent 1px);
  background-size: 30px 30px;
  opacity: 0.3;
}

/* เอฟเฟกต์จุดแสง */
.particles {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.particle {
  position: absolute;
  background: rgba(0, 234, 255, 0.6);
  border-radius: 50%;
  opacity: 0;
  animation: particleFloat 15s infinite linear;
}

@keyframes particleFloat {
  0% {
    transform: translateY(0) translateX(0);
    opacity: 0;
  }
  10% {
    opacity: 0.8;
  }
  90% {
    opacity: 0.7;
  }
  100% {
    /* เคลื่อนไหวขึ้นอย่างมากเพื่อให้อนุภาคลอยขึ้นมาในมุมมอง */
    transform: translateY(-300px) translateX(50px);
    opacity: 0;
  }
}

/* ลำแสงไซไฟ */
.light-beams {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}

.beam {
  position: absolute;
  background: linear-gradient(90deg, rgba(0, 234, 255, 0) 0%, rgba(0, 234, 255, 0.6) 50%, rgba(0, 234, 255, 0) 100%);
  height: 1px;
  filter: blur(1px);
  animation: beamMove 20s infinite linear;
}

@keyframes beamMove {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* แสงวงกลมไซไฟ */
.glow-circle {
  position: absolute;
  border-radius: 50%;
  filter: blur(50px);
  opacity: 0.1;
  animation: pulse 8s infinite ease-in-out;
  pointer-events: none;
}

@keyframes pulse {
  0%, 100% {
    opacity: 0.1;
    transform: scale(1);
  }
  50% {
    opacity: 0.15;
    transform: scale(1.1);
  }
}

.page-container { 
  width: 100%; 
  max-width: 500px; 
  padding: 0 15px 15px;
  margin: 0 auto;
  display: flex; 
  flex-direction: column; 
  position: relative;
  z-index: 1;
  flex: 1;
  justify-content: flex-start;
  padding-top: 10px;
}

/* ปรับพื้นที่ข้อมูลหุ้น - ปรับเป็นการแสดง 5 แถว */
.stock-ticker-wrapper {
  width: 100%;
  margin: 8px auto 16px;
  position: relative;
}
.ticker-title {
  text-align: center;
  font-family: 'Orbitron', sans-serif;
  font-size: 16px;
  color: var(--accent-gold);
  margin-bottom: 8px;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
  letter-spacing: 1px;
}
.stock-ticker { 
  background: transparent; 
  padding: 4px 0; 
  overflow: hidden; 
  height: 120px; /* ปรับเป็นความสูงของ 5 แถว (5 * 24px) */
  display: none; 
  width: 100%; 
  position: relative;
  mask-image: linear-gradient(to bottom, 
    rgba(0,0,0,0) 0%,
    rgba(0,0,0,1) 10%,
    rgba(0,0,0,1) 90%,
    rgba(0,0,0,0) 100%);
  -webkit-mask-image: linear-gradient(to bottom, 
    rgba(0,0,0,0) 0%,
    rgba(0,0,0,1) 10%,
    rgba(0,0,0,1) 90%,
    rgba(0,0,0,0) 100%);
}
.ticker-container { 
  height: 100%; 
  position: relative; 
  overflow: hidden;
  box-shadow: 0 0 15px rgba(0, 234, 255, 0.15);
  border-radius: 6px;
  background: rgba(2, 12, 27, 0.25);
  backdrop-filter: blur(3px);
  border: 1px solid rgba(0, 234, 255, 0.1);
}
.ticker-list { 
  position: absolute; 
  top: 0; 
  left: 0; 
  width: 100%; 
  animation: ticker-vertical 35s linear infinite; 
}
.ticker-item { 
  font-size: 13px; 
  padding: 4px 12px; 
  color: var(--primary-color); 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  white-space: nowrap; 
  height: 24px; 
  font-family: 'Orbitron', monospace; 
  text-shadow: 0 0 8px var(--glow-color), 0 0 15px rgba(0,238,255,0.5);
  background: rgba(2, 12, 27, 0.3);
  margin: 2px 4px;
  border-radius: 4px;
  transition: all 0.3s ease;
  border: 1px solid rgba(0, 234, 255, 0.15);
}
.ticker-item:hover {
  background: rgba(2, 12, 27, 0.5);
  transform: scale(1.02);
  border-color: rgba(0, 234, 255, 0.3);
  box-shadow: 0 0 10px rgba(0, 234, 255, 0.2);
}
.ticker-symbol { 
  font-weight: 600; 
  letter-spacing: 0.5px; 
  font-size: 12px; 
}
.ticker-price { 
  font-weight: bold; 
  margin-left: 8px; 
  display: flex; 
  align-items: center; 
  font-size: 12px; 
}
.price-change { 
  margin-left: 6px; 
  font-size: 11px; 
}
.up { color: var(--accent-green); }
.down { color: var(--accent-red); }
@keyframes ticker-vertical { 
  0% { transform: translateY(0); } 
  100% { transform: translateY(-50%); } /* ปรับเป็นการเคลื่อนไหว 50% (10 แถว/20 แถว) */
}

main { 
  position: relative; 
  text-align: center; 
  width: 100%; 
  display: flex; 
  flex-direction: column; 
  justify-content: flex-start;
  flex: 1;
  margin-top: 5px;
}
.content-wrapper { 
  width: 100%; 
  max-width: 400px; 
  margin: 0 auto; 
}
.robot-img { margin-bottom: 10px; }
.robot-img img { 
  width: 120px;
  margin: 0 auto; 
  display: block; 
  filter: drop-shadow(0 0 10px var(--primary-color)); 
  animation: float 6s ease-in-out infinite; 
}
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.title { 
  font-size: 1.5rem;
  margin: 5px 0 4px;
  color: var(--primary-color); 
  text-shadow: 0 0 10px rgba(0,238,255,0.8); 
  font-family: 'Orbitron', sans-serif; 
  letter-spacing: 0.5px; 
}
.subtitle { 
  font-size: 0.95rem;
  margin-bottom: 12px;
  color: var(--accent-gold); 
  font-weight: 500; 
}

/* ปรับการจัดวางข้อความการ์ด */
.card { 
  background: var(--card-bg); 
  border: 1px solid var(--primary-color); 
  border-radius: 10px; 
  padding: 15px 12px;
  margin: 0 auto 12px;
  box-shadow: 0 0 12px rgba(0,238,255,0.3); 
  font-size: 0.85rem;
  width: 100%; 
  line-height: 1.5;
}
.accuracy { 
  font-size: 0.9rem;
  margin-bottom: 6px;
  font-weight: 600;
}
.percent { color: var(--accent-green); font-weight: bold; }
.desc { 
  font-size: 0.8rem;
  line-height: 1.4;
  text-align: center;
}
.highlight {
  color: var(--accent-gold);
  font-weight: 700;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.7);
  display: inline-block;
  animation: countBounce 0.4s ease-out;
}
/* ปรับปรุงแอนิเมชั่นตัวนับคน */
@keyframes countBounce {
  0%, 100% { 
    transform: scale(1); 
    color: var(--accent-gold);
  }
  50% { 
    transform: scale(1.3); 
    color: #ffed4e;
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.9);
  }
}

/* สไตล์สถานะข้อผิดพลาด */
.input-error {
  border: 2px solid red !important;
  animation: shake 0.3s ease-in-out;
}

/* แอนิเมชั่นการสั่น */
@keyframes shake {
  0% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
  100% { transform: translateX(0); }
}

.input-group { margin: 12px 0; width: 100%; }
.input-group input { 
  width: 100%; 
  padding: 11px 12px;
  border-radius: 8px; 
  border: 1px solid var(--primary-color); 
  background: rgba(10, 22, 35, 0.7); 
  color: #fff; 
  font-size: 0.9rem;
  font-family: 'Exo 2', sans-serif; 
  transition: all 0.3s ease;
}
.input-group input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(0, 234, 255, 0.3);
}

/* เสริมเอฟเฟกต์แอนิเมชั่นปุ่มเริ่มต้น */
.btn { 
  background: linear-gradient(90deg, var(--primary-color), #0077ff); 
  color: #fff; 
  border: none; 
  padding: 13px 15px;
  border-radius: 8px; 
  cursor: pointer; 
  font-weight: bold; 
  font-size: 0.95rem;
  box-shadow: 0 0 20px rgba(0,238,255,0.7); 
  width: 100%; 
  margin-top: 8px;
  font-family: 'Exo 2', sans-serif; 
  letter-spacing: 0.5px; 
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  animation: gentlePulse 2s infinite;
}
.btn:hover { 
  transform: translateY(-3px); 
  box-shadow: 0 8px 25px rgba(0,238,255,0.9);
  animation: none;
}
.btn:active {
  transform: translateY(1px);
  box-shadow: 0 2px 15px rgba(0,238,255,0.6);
}
.btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transition: left 0.7s ease;
}
.btn:hover::after {
  left: 100%;
}
/* แอนิเมชั่นชีพจรที่โดดเด่นกว่า */
@keyframes gentlePulse {
  0%, 100% { box-shadow: 0 0 20px rgba(0,238,255,0.7); }
  50% { box-shadow: 0 0 30px rgba(0,238,255,0.9), 0 0 40px rgba(0,238,255,0.6); }
}

/* ปรับตำแหน่งโมดอล */
.ai-modal { display: none; position: fixed; inset: 0; z-index: 10000; }
.ai-modal .modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(5px); }
.ai-modal .modal-content { 
  position: relative; 
  width: 90%; 
  max-width: 340px; 
  margin: 30vh auto; /* ปรับจาก 35vh */
  background: rgba(10, 22, 35, 0.95); 
  border-radius: 14px; 
  padding: 18px 14px; 
  color: #fff; 
  border: 1px solid var(--primary-color);
  max-height: 70vh;
  overflow-y: auto;
}
.modal-title { font-size: 16px; font-weight: 600; text-align: center; margin-bottom: 14px; color: var(--primary-color); font-family: 'Orbitron', sans-serif; }
.modal-text { font-size: 13px; text-align: center; margin-bottom: 16px; color: var(--text-light); line-height: 1.5; }
.stock-code { 
  color: var(--accent-gold); 
  font-weight: bold; 
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.7);
  font-size: 1.1em;
  padding: 2px 4px;
  border-radius: 4px;
  background: rgba(255, 215, 0, 0.1);
}
.modal-close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: transparent;
  border: none;
  color: #aaa;
  font-size: 24px;
  cursor: pointer;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.3s ease;
}
.modal-close-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}
.modal-content-wrapper { margin-bottom: 16px; }
.report-details { margin: 15px 0; padding: 10px; background: rgba(0, 20, 40, 0.5); border-radius: 8px; border: 1px solid rgba(0, 234, 255, 0.2); }
.detail-title { font-size: 13px; font-weight: 600; color: var(--primary-color); margin-bottom: 8px; text-align: center; }
.detail-list { padding-left: 15px; margin: 0; }
.detail-list li { font-size: 12px; color: var(--text-light); margin-bottom: 6px; line-height: 1.4; }
.detail-list li:last-child { margin-bottom: 0; }
.modal-info { font-size: 12px; color: var(--text-light); margin-bottom: 10px; line-height: 1.4; }
.modal-info:last-child { margin-bottom: 0; }
.progress-item { margin-bottom: 12px; }
.progress-label { font-size: 12px; margin-bottom: 4px; display: block; color: var(--text-light); }
.progress-bar { width: 100%; height: 10px; border-radius: 6px; background: #1e293b; overflow: hidden; position: relative; }
.progress-fill { width: 0%; height: 100%; background: linear-gradient(90deg, #00dcf4, #15a223); border-radius: 6px; transition: width 0.3s ease; }
.btn-whatsapp { display: block; width: 100%; padding: 12px; background: #15a223; color: #fff; font-size: 14px; font-weight: 600; border-radius: 7px; cursor: pointer; text-align: center; font-family: 'Exo 2', sans-serif; margin-top: 5px; }

/* แบนเนอร์คุกกี้แบบใหม่ - เวอร์ชันสองปุ่ม */
#cookie-banner { 
  position: fixed; 
  bottom: 0; 
  left: 0; 
  right: 0; 
  background: rgba(2, 12, 27, 0.95); 
  color: var(--text-light); 
  padding: 15px; 
  text-align: center; 
  font-size: 13px; 
  z-index: 20000; 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  border-top: 1px solid var(--primary-color);
  box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.3);
}
#cookie-banner p {
  margin-bottom: 12px;
  max-width: 400px;
  line-height: 1.5;
}
.cookie-buttons {
  display: flex;
  gap: 10px;
}
#cookie-decline, #cookie-accept { 
  padding: 8px 16px; 
  border: none;
  border-radius: 5px; 
  cursor: pointer; 
  font-size: 13px;
  font-weight: 500;
  transition: all 0.3s ease;
}
#cookie-accept { 
  background: var(--accent-green); 
  color: #000; 
}
#cookie-accept:hover {
  background: #10d466;
  transform: translateY(-2px);
}
#cookie-decline { 
  background: transparent; 
  color: var(--text-light);
  border: 1px solid rgba(255, 255, 255, 0.3);
}
#cookie-decline:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* ปรับสไตล์ฟุตเตอร์ - ลบพื้นหลังและขอบ */
.footer {
  width: 100%;
  max-width: 400px;
  margin: 18px auto 0;
  padding: 8px 0;
  box-sizing: border-box;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-light);
  position: relative;
  z-index: 2;
  background: transparent;
  border: none;
  backdrop-filter: none;
}

/* ลบเส้นไล่ระดับสีเหนือฟุตเตอร์ */
.footer::before {
  display: none;
}

.footer-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.8rem;
  margin-bottom: 6px;
  color: var(--accent-gold);
  text-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
  letter-spacing: 0.5px;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.footer-link {
  color: var(--primary-color);
  text-decoration: none;
  font-size: 0.7rem;
  transition: all 0.3s ease;
  position: relative;
  padding: 2px 4px;
  white-space: nowrap;
}

.footer-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--primary-color);
  transition: width 0.3s ease;
  box-shadow: 0 0 5px var(--primary-color);
}

.footer-link:hover {
  color: var(--accent-green);
  text-shadow: 0 0 8px rgba(0, 234, 255, 0.7);
}

.footer-link:hover::after {
  width: 100%;
}

.loading-indicator { 
  height: 100px;
  display: flex; 
  justify-content: center; 
  align-items: center; 
  color: var(--primary-color); 
  font-family: 'Orbitron', sans-serif; 
  font-size: 12px;
  text-shadow: 0 0 5px var(--glow-color); 
  width: 100%; 
  margin: 8px auto 12px;
  background: transparent;
  border-radius: 6px;
  box-shadow: 0 0 20px rgba(0, 234, 255, 0.2);
  background: rgba(2, 12, 27, 0.15);
  backdrop-filter: blur(2px);
}
.loading-dots { display: inline-flex; margin-left: 6px; }
.loading-dots span { width: 5px; height: 5px; margin: 0 2px; background: var(--primary-color); border-radius: 50%; animation: bounce 1.5s infinite ease-in-out; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

/* แก้ไขเฉพาะสำหรับ Safari บน Apple */
@media not all and (min-resolution:.001dpcm) { 
  @supports (-webkit-appearance:none) {
    /* สไตล์เฉพาะ Safari */
    body {
      height: 100vh;
      display: flex;
      flex-direction: column;
      justify-content: flex-start;
    }
    .page-container {
      margin: 0 auto;
      padding-top: 15px;
    }
  }
}

@media (max-height: 700px) { 
  .page-container { padding: 0 15px 10px; } 
  .robot-img img { width: 90px; }
  .title { font-size: 1.3rem; } 
  .card { padding: 10px; margin-bottom: 8px; } 
  .ai-modal .modal-content { margin: 12vh auto; /* ปรับจาก 15vh */}
  .footer { margin-top: 12px; padding: 6px 0; }
}

@media (max-height: 600px) and (max-width: 480px) {
  .ai-modal .modal-content {
    margin: 5vh auto;
    max-height: 85vh;
  }
  
  .modal-content-wrapper {
    max-height: 60vh;
    overflow-y: auto;
  }
}
@media (max-height: 600px) { 
  .stock-ticker, .loading-indicator { height: 90px; }
  .ticker-item { height: 18px; font-size: 11px; } 
  .ai-modal .modal-content { margin: 8vh auto; /* ปรับจาก 10vh */ padding: 15px 10px; }
  .footer { margin-top: 10px; padding: 5px 0; font-size: 0.7rem; }
  .footer-title { font-size: 0.75rem; margin-bottom: 5px; }
  .footer-links { gap: 10px; }
  .footer-link { font-size: 0.65rem; }
  
  /* บีบอัดพื้นที่แนวตั้งเพิ่มเติม */
  .robot-img { margin-bottom: 5px; }
  .title { margin: 3px 0 2px; }
  .subtitle { margin-bottom: 8px; }
  .input-group { margin: 8px 0; }
  .btn { margin-top: 5px; padding: 10px 12px; }
}
@media (max-width: 480px) {
  .footer-links {
    flex-direction: row;
    gap: 10px;
  }
  .footer {
    max-width: 350px;
  }
}
@media (max-width: 380px) {
  .footer-links {
    gap: 8px;
  }
  .footer-link {
    font-size: 0.65rem;
    padding: 1px 3px;
  }
}

/* ปรับปรุงโมดอลสำหรับมือถือ */
@media (max-width: 480px) {
  .ai-modal .modal-content {
    width: 95%;
    padding: 15px 12px;
    max-height: 80vh;
    margin: 25vh auto; /* ปรับจาก 30vh */
  }
  
  /* ปรับปรุงสำหรับอุปกรณ์หน้าจอเล็ก */
  @media (max-width: 360px) {
    .ai-modal .modal-content {
      padding: 12px 10px;
      margin: 20vh auto; /* ปรับจาก 25vh */
    }
    
    .modal-title {
      font-size: 14px;
    }
    
    .modal-text {
      font-size: 11px;
    }
    
    .detail-list li {
      font-size: 10px;
    }
    
    .modal-info {
      font-size: 10px;
    }
    
    .btn-whatsapp {
      padding: 8px;
      font-size: 12px;
    }
  }
  
  .modal-title {
    font-size: 15px;
    margin-bottom: 12px;
  }
  
  .modal-text {
    font-size: 12px;
    margin-bottom: 14px;
  }
  
  .report-details {
    padding: 8px;
    margin: 12px 0;
  }
  
  .detail-title {
    font-size: 12px;
    margin-bottom: 6px;
  }
  
  .detail-list li {
    font-size: 11px;
    margin-bottom: 5px;
  }
  
  .modal-info {
    font-size: 11px;
    margin-bottom: 8px;
  }
  
  .btn-whatsapp {
    padding: 10px;
    font-size: 13px;
  }
}

/* ปรับปรุงอินพุตสำหรับมือถือ */
@media (max-width: 480px) {
  .input-group input { 
    font-size: 16px; /* ป้องกันการซูมของ Safari บน iOS */
    padding: 12px 15px;
  }
  
  /* แน่ใจว่าหน้าจะไม่ถูกบีบอัดเมื่อเปิดคีย์บอร์ด */
  .page-container {
    min-height: 100vh;
    padding-bottom: 20px;
  }
  
  /* ปรับหน้าเมื่อเปิดคีย์บอร์ด */
  body.keyboard-visible {
    position: fixed;
    width: 100%;
  }
}

/* ปรับปรุงสำหรับอุปกรณ์หน้าจอเล็กพิเศษ */
@media (max-width: 360px) {
  .input-group input {
    padding: 10px 12px;
    font-size: 15px;
  }
}