@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
  body {
    background-color: #FAF6EF;
    color: #3A3324;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    letter-spacing: -0.01em;
  }

  /* Better global defaults */
  h1, h2, h3, h4, h5 {
    text-wrap: balance;
  }
  p {
    text-wrap: pretty;
  }

  /* Global scrollbar */
  ::-webkit-scrollbar { width: 6px; }
  ::-webkit-scrollbar-track { background: #FAF6EF; }
  ::-webkit-scrollbar-thumb { background: #E8D3A5; border-radius: 99px; }
  ::-webkit-scrollbar-thumb:hover { background: #CFAF6E; }
  html { scrollbar-color: #E8D3A5 #FAF6EF; scrollbar-width: thin; }

  /* Remove default blue focus outlines, add brand-consistent ones */
  :focus-visible {
    outline: 2px solid #CFAF6E;
    outline-offset: 2px;
    border-radius: 4px;
  }
}

@layer components {
  /* ========== BUTTONS ========== */
  .btn-gold {
    @apply bg-gradient-to-r from-[#CFAF6E] to-[#B89655] text-white font-bold tracking-wide px-8 py-4 rounded-xl transition-all duration-300 inline-block text-center cursor-pointer;
    box-shadow: 0 6px 20px rgba(207, 175, 110, 0.35);
  }
  .btn-gold:hover {
    @apply from-[#B89655] to-[#A38245];
    box-shadow: 0 10px 25px rgba(207, 175, 110, 0.5);
    transform: translateY(-2px);
  }

  .btn-outline {
    @apply border border-brand-pale text-brand-text font-medium px-6 py-3 rounded-xl hover:bg-brand-gold hover:text-white hover:border-brand-gold transition-all duration-300 inline-block text-center cursor-pointer;
  }
  .btn-outline:hover {
    box-shadow: 0 6px 20px rgba(207, 175, 110, 0.2);
    transform: translateY(-1px);
  }

  /* ========== SECTION LABEL — editorial style ========== */
  .section-label {
    @apply text-xs font-bold uppercase tracking-[0.2em] text-brand-text/60 flex items-center gap-3;
  }
  .section-label::before {
    content: '';
    display: inline-block;
    width: 24px;
    height: 1.5px;
    background: #CFAF6E;
    flex-shrink: 0;
  }

  /* ========== SECTION DIVIDER — decorative gold diamond ========== */
  .section-divider {
    @apply flex items-center justify-center gap-4 my-4;
  }
  .section-divider::before,
  .section-divider::after {
    content: '';
    height: 1px;
    width: 40px;
    background: linear-gradient(to right, transparent, #E8D3A5);
  }
  .section-divider::after {
    background: linear-gradient(to left, transparent, #E8D3A5);
  }
  .section-divider .diamond {
    width: 6px;
    height: 6px;
    background: #CFAF6E;
    transform: rotate(45deg);
    flex-shrink: 0;
  }

  /* ========== EDITORIAL TAB BAR ========== */
  .tab-bar {
    @apply flex gap-1 border-b border-brand-pale/60;
  }
  .tab-bar-btn {
    @apply relative px-6 py-3.5 text-sm font-semibold tracking-wide text-brand-text/50 transition-all duration-300 cursor-pointer;
  }
  .tab-bar-btn:hover {
    @apply text-brand-text/80;
  }
  .tab-bar-btn.active {
    @apply text-brand-text;
  }
  .tab-bar-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: #CFAF6E;
  }
  .tab-bar-btn .tab-count {
    @apply inline-flex items-center justify-center ml-1.5 text-[10px] font-bold bg-brand-soft text-brand-text/60 rounded-full w-5 h-5;
  }
  .tab-bar-btn.active .tab-count {
    @apply bg-brand-gold/15 text-brand-gold;
  }

  /* ========== REVEAL ON SCROLL ========== */
  .reveal-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: opacity, transform;
  }
  .reveal-on-scroll.revealed {
    opacity: 1;
    transform: translateY(0);
  }

  /* Staggered delays for child elements */
  .reveal-delay-1 { transition-delay: 0.1s; }
  .reveal-delay-2 { transition-delay: 0.2s; }
  .reveal-delay-3 { transition-delay: 0.3s; }
  .reveal-delay-4 { transition-delay: 0.4s; }
  .reveal-delay-5 { transition-delay: 0.5s; }
  .reveal-delay-6 { transition-delay: 0.6s; }

  /* Reveal from left */
  .reveal-from-left {
    opacity: 0;
    transform: translateX(-30px);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: opacity, transform;
  }
  .reveal-from-left.revealed {
    opacity: 1;
    transform: translateX(0);
  }

  /* Reveal from right */
  .reveal-from-right {
    opacity: 0;
    transform: translateX(30px);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: opacity, transform;
  }
  .reveal-from-right.revealed {
    opacity: 1;
    transform: translateX(0);
  }

  /* Scale reveal for cards */
  .reveal-scale {
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: opacity, transform;
  }
  .reveal-scale.revealed {
    opacity: 1;
    transform: scale(1);
  }

  /* ========== MEGA MENU ========== */
  .mega-menu-content {
    @apply absolute left-0 w-full bg-white shadow-xl border-t border-brand-gold/10 opacity-0 invisible transition-all duration-300 z-[60] pt-8 pb-12 cursor-default pointer-events-none;
    top: 100%;
    transform: translateY(10px);
  }
  .mega-menu-trigger.is-open .mega-menu-content {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
  }

  /* ========== TREATMENT CARDS ========== */
  .treatment-card-circle {
    @apply flex flex-col items-center text-center group;
  }
  .treatment-card-circle .img-wrapper {
    @apply w-40 h-40 rounded-full overflow-hidden bg-brand-cream mb-4 border-[3px] border-transparent group-hover:border-brand-gold transition duration-300 shadow-md group-hover:shadow-xl relative;
  }
  .treatment-card-circle img {
    @apply w-full h-full object-cover group-hover:scale-110 transition duration-700;
  }
  .treatment-card-circle h4 {
    @apply font-bold text-brand-text mb-2 group-hover:text-brand-gold transition-colors text-lg px-2;
  }
  .treatment-card-circle .action {
    @apply text-brand-text text-sm font-medium flex items-center gap-1 opacity-0 group-hover:opacity-100 transform translate-y-2 group-hover:translate-y-0 transition-all duration-300;
  }

  /* ========== TAB BUTTONS (legacy) ========== */
  .treatment-tab-btn {
    @apply px-8 py-3 rounded-full text-sm sm:text-base font-bold tracking-wide bg-white text-brand-gold border border-brand-gold transition-all cursor-pointer hover:bg-brand-gold/5;
  }
  .treatment-tab-btn.active {
    @apply bg-brand-gold text-white border-brand-gold shadow-md hover:text-white hover:bg-brand-dark hover:border-brand-dark;
  }

  .filter-chip {
    @apply px-5 py-2 rounded-full border border-brand-pale text-brand-text text-sm font-medium hover:border-brand-gold hover:text-brand-text transition-colors cursor-pointer bg-white whitespace-nowrap;
  }
  .filter-chip.active {
    @apply bg-brand-pale/20 border-brand-gold text-brand-text;
  }

  /* ========== MARQUEE (reviews) ========== */
  .animate-marquee-loop {
    animation: marquee-scroll 60s linear infinite;
  }
  .animate-marquee-loop:hover {
    animation-play-state: paused;
  }
  @keyframes marquee-scroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
  }

  /* ========== REVIEW CARD QUOTE ========== */
  .review-quote::before {
    content: '\201C';
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 3rem;
    line-height: 1;
    color: #E8D3A5;
    position: absolute;
    top: 16px;
    right: 20px;
    opacity: 0.5;
  }

  /* ========== CHATBOT STYLES ========== */
  .typing-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #CFAF6E;
    animation: typingBounce 1.2s ease-in-out infinite;
  }
  @keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
  }

  .chat-quick-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid #CFAF6E;
    background: #F2E6C9;
    color: #3A3324;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    animation: btnFadeIn 0.3s ease forwards;
    opacity: 0;
    white-space: nowrap;
    line-height: 1.3;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
  }
  .chat-quick-btn:hover:not(:disabled) {
    border-color: #CFAF6E;
    background: #FAF6EF;
    color: #CFAF6E;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(207, 175, 110, 0.15);
  }
  .chat-quick-btn:disabled {
    cursor: default;
  }
  .chat-quick-btn-selected {
    background: #CFAF6E !important;
    color: white !important;
    border-color: #CFAF6E !important;
    opacity: 1 !important;
  }
  @keyframes btnFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .chat-msg-enter {
    animation: msgSlideIn 0.3s ease forwards;
  }
  @keyframes msgSlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
  }

  #chat-messages::-webkit-scrollbar { width: 4px; }
  #chat-messages::-webkit-scrollbar-track { background: transparent; }
  #chat-messages::-webkit-scrollbar-thumb { background: #E8D3A5; border-radius: 10px; }

  .chat-wa-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 12px;
    background: #25D366;
    color: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
  }
  .chat-wa-btn:hover {
    background: #1ebe5a;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
  }

  .hide-scrollbar::-webkit-scrollbar { display: none; }
  .hide-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
}

/* ========== COMPREHENSIVE MOBILE RESPONSIVE FIXES ========== */

/* --- Global mobile defaults --- */
@media (max-width: 767px) {

  /* Prevent any accidental horizontal overflow */
  html, body {
    overflow-x: hidden !important;
  }

  /* Hero carousel: shorter on phones */
  .h-\[60vh\] {
    height: 45vh !important;
  }

  /* Reduce top margin under sticky header on mobile */
  .mt-\[80px\] {
    margin-top: 64px !important;
  }

  /* Section padding: tighter vertical spacing on mobile */
  .py-24 {
    padding-top: 3rem !important;
    padding-bottom: 3rem !important;
  }
  .py-20 {
    padding-top: 2.5rem !important;
    padding-bottom: 2.5rem !important;
  }

  /* Section headings: scale down */
  .text-4xl {
    font-size: 1.75rem !important;
    line-height: 2rem !important;
  }
  .text-5xl, .lg\:text-5xl {
    font-size: 1.75rem !important;
    line-height: 2.25rem !important;
  }

  /* Why Choose cards — single column on very small screens, 2 on wider phones */
  .grid-cols-2 {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Trust section: image + text stacked */
  .md\:col-span-7,
  .md\:col-span-5 {
    grid-column: span 1 !important;
  }

  /* Hide the floating Google rating card on mobile (it overflows) */
  .md\:block.-right-6 {
    display: none !important;
  }

  /* Treatment tab buttons: smaller padding on mobile */
  .treatment-tab-btn {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    font-size: 0.8rem !important;
  }

  /* Treatment service cards: 2-column on mobile */
  .lg\:grid-cols-4 {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Treatment options: 2 columns instead of 4 */
  .sm\:grid-cols-2 {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Google Map section — shorter on mobile */
  .rounded-3xl[style*="height: 500px"] {
    height: 300px !important;
  }

  /* Google Map info card: stack vertically on mobile, allow wrapping */
  .bg-white\/95.backdrop-blur-md {
    flex-direction: column !important;
    white-space: normal !important;
    text-align: center !important;
    gap: 0.5rem !important;
    padding: 0.75rem 1rem !important;
    max-width: 90vw !important;
  }
  .bg-white\/95.backdrop-blur-md .ml-2 {
    margin-left: 0 !important;
  }
  .bg-white\/95.backdrop-blur-md .w-10 {
    width: 2rem !important;
    height: 2rem !important;
  }

  /* Reviews section — better sizing */
  .md\:col-span-1,
  .md\:col-span-3 {
    grid-column: span 1 !important;
  }
  .md\:grid-cols-4 {
    grid-template-columns: 1fr !important;
  }

  /* Review cards — full phone width */
  .w-\[320px\] {
    width: 280px !important;
  }

  /* Footer links grid: 2 columns on mobile */
  .lg\:grid-cols-6 {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Footer CTA card: stack */
  .lg\:col-span-2 {
    grid-column: span 1 !important;
  }

  /* Floating buttons: make room for each other */
  .fixed.bottom-6.left-6 {
    bottom: 1rem !important;
    left: 0.75rem !important;
    width: 3rem !important;
    height: 3rem !important;
    padding: 0.5rem !important;
  }
  .fixed.bottom-6.left-6 .text-3xl {
    font-size: 1.5rem !important;
  }
  .fixed.bottom-6.right-6#chat-bot-btn {
    bottom: 1rem !important;
    right: 0.75rem !important;
    padding: 0.5rem 0.75rem !important;
    font-size: 0.75rem !important;
    gap: 0.375rem !important;
  }
  .fixed.bottom-6.right-6#chat-bot-btn .text-xl {
    font-size: 1rem !important;
  }
  .fixed.bottom-6.right-6#chat-bot-btn .text-sm {
    font-size: 0.7rem !important;
  }

  /* Chatbot window: full-screen on mobile */
  #chat-window {
    width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    bottom: 0 !important;
    right: 0 !important;
    border-radius: 0 !important;
  }

  /* Mobile menu slide-in: full height without gap */
  #mobile-menu {
    width: 85vw !important;
  }

  /* Why Choose 19BS bottom row cards: fill width on mobile */
  .md\:w-1\/2 {
    width: 100% !important;
  }

  /* Clinic gallery images: shorter on mobile */
  .h-\[350px\] {
    height: 200px !important;
  }
  .h-\[260px\] {
    height: 180px !important;
  }

  /* Ensure long text doesn't overflow */
  .max-w-xl,
  .max-w-3xl,
  .max-w-sm {
    max-width: 100% !important;
  }

  /* Header: smaller logo and tighter padding */
  header .h-12 {
    height: 2.5rem !important;
  }
  header .py-4 {
    padding-top: 0.75rem !important;
    padding-bottom: 0.75rem !important;
  }

  /* Book Appointment button in header: hidden on small phones, shown in hamburger */
  .hidden.md\:flex[href="contact.html"] {
    display: none !important;
  }
}

/* Very small screens (360px and below) */
@media (max-width: 374px) {
  .grid-cols-2 {
    grid-template-columns: 1fr !important;
  }
  .lg\:grid-cols-4,
  .md\:grid-cols-4 {
    grid-template-columns: 1fr !important;
  }
  .lg\:grid-cols-6 {
    grid-template-columns: 1fr !important;
  }
}

/* Touch-friendly: make tappable areas bigger */
@media (hover: none) and (pointer: coarse) {
  a, button {
    display: inline-block;
    min-height: 44px;
    display: flex;
    align-items: center;
    min-height: 44px;
    min-width: 44px;
  }
  /* Show hover states on gallery images always (no hover on touch) */
  .group .opacity-0 {
    opacity: 1 !important;
  }
  /* Prevent hover scale on touch devices (causes jagged feel) */
  .group:hover img {
    transform: none !important;
  }
}


/* Enable hardware acceleration to prevent lag/stutter */
.transition-all,
.transition-transform,
.reveal-on-scroll,
.reveal-scale,
.mega-menu-content {
    backface-visibility: hidden;
    transform: translateZ(0);
}
/* Enhanced text hover for main interactive texts */
.hover-text-glow:hover {
    color: #B89655;
    text-shadow: 0 0 8px rgba(207, 175, 110, 0.4);
}


/* Deep Interactivity & Micro-Animations */
.btn-gold:active, .btn-outline:active, .treatment-tab-btn:active {
    transform: scale(0.96) translateZ(0) !important;
}
.social-icon-anim {
    display: inline-block;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.3s ease;
    transform: translateZ(0);
}
.social-icon-anim:hover {
    transform: scale(1.2) rotate(8deg) translateZ(0);
    color: #CFAF6E;
}
.list-item-anim {
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), color 0.3s ease;
    transform: translateZ(0);
    cursor: default;
}
.list-item-anim:hover {
    transform: translateX(12px) translateZ(0);
    color: #B89655;
}
.heading-hover-anim {
    transition: color 0.4s ease, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    transform: translateZ(0);
}
.heading-hover-anim:hover {
    color: #B89655;
    transform: translateY(-2px) translateZ(0);
}
.logo-anim {
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.5s ease;
    transform: translateZ(0);
}
.logo-anim:hover {
    transform: scale(1.05) translateZ(0);
    filter: drop-shadow(0 4px 6px rgba(207, 175, 110, 0.2));
}
.icon-bounce-anim {
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform: translateZ(0);
}
.icon-bounce-anim:hover {
    transform: scale(1.15) translateY(-2px) translateZ(0);
    color: #CFAF6E;
}
