/* MADA Centralized Agro-Tourism — subtle UI polish, responsive-first. */
:root {
  --mada-green:#059669;
  --mada-green-dark:#047857;
  --mada-soft:#ecfdf5;
  --mada-line:#e2e8f0;
}
html { scroll-behavior:smooth; }
body { overflow-x:hidden; }
img { max-width:100%; }

/* Professional motion: subtle, never gaming/neon. */
.mada-card, .destination-card, .package-card, .stat-card,
main .bg-white.rounded-2xl.shadow-sm, main .bg-white.rounded-3xl.shadow-sm, main .bg-white.rounded-3xl.shadow-lg {
  transition:transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}
@media (hover:hover) {
  .mada-card:hover, .destination-card:hover, .package-card:hover,
  main .bg-white.rounded-2xl.shadow-sm:hover, main .bg-white.rounded-3xl.shadow-sm:hover, main .bg-white.rounded-3xl.shadow-lg:hover {
    transform:translateY(-2px);
    box-shadow:0 14px 32px rgba(15,23,42,.08);
  }
}
button, a, input, select, textarea { transition:box-shadow .18s ease, border-color .18s ease, background-color .18s ease, transform .18s ease; }
button:active, a.mada-action:active { transform:scale(.985); }
:focus-visible { outline:3px solid rgba(16,185,129,.22); outline-offset:2px; }

/* Reveal helper; JS below only adds the class when IntersectionObserver exists. */
.mada-reveal { opacity:0; transform:translateY(12px); }
.mada-reveal.mada-visible { opacity:1; transform:none; transition:opacity .55s ease, transform .55s ease; }
@media (prefers-reduced-motion:reduce) {
  *, *::before, *::after { animation-duration:.01ms !important; transition-duration:.01ms !important; scroll-behavior:auto !important; }
  .mada-reveal { opacity:1; transform:none; }
}

/* Images feel alive without over-animation. */
.mada-img-zoom { overflow:hidden; }
.mada-img-zoom img { transition:transform .45s ease; }
@media (hover:hover) { .mada-img-zoom:hover img { transform:scale(1.035); } }

/* More usable tables on phone. */
.mada-table-wrap, .table-responsive { max-width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; }
table { max-width:100%; }

/* Touch targets and compact mobile spacing. */
@media (max-width:767px) {
  button, .btn, a[role="button"] { min-height:40px; }
  main, .main-content { max-width:100vw; }
  .mada-mobile-stack { display:flex !important; flex-direction:column !important; align-items:stretch !important; }
  .mada-mobile-full { width:100% !important; }
  .mada-hide-mobile { display:none !important; }
  .mada-calendar-scroll { overflow-x:auto; padding-bottom:.25rem; }
  .mada-calendar-min { min-width:720px; }
}

/* Notification heartbeat: gentle. */
.mada-notification-pulse { position:relative; }
.mada-notification-pulse::after {
  content:""; position:absolute; inset:-3px; border-radius:inherit;
  border:2px solid rgba(16,185,129,.28); animation:madaPulse 2.2s ease-out infinite;
}
@keyframes madaPulse { 0%{transform:scale(.9);opacity:.7} 70%,100%{transform:scale(1.3);opacity:0} }

/* Skeleton utility for async weather/chat loading. */
.mada-skeleton { position:relative; overflow:hidden; background:#e2e8f0; }
.mada-skeleton::after { content:""; position:absolute; inset:0; transform:translateX(-100%); background:linear-gradient(90deg,transparent,rgba(255,255,255,.55),transparent); animation:madaShimmer 1.25s infinite; }
@keyframes madaShimmer { 100%{transform:translateX(100%)} }

/* Chat widget: responsive and readable. */
#agroBot { max-width:calc(100vw - 1.25rem); }
#botPanel { max-width:calc(100vw - 2rem); }
#botMessages { overscroll-behavior:contain; }
#botMessages .bot-message { overflow-wrap:anywhere; }
@media (max-width:480px) {
  #agroBot { right:.75rem !important; bottom:.75rem !important; }
  #botPanel { right:0 !important; width:calc(100vw - 1.5rem) !important; height:min(70vh,520px) !important; }
}

/* Dashboard/chart wrappers don't force horizontal overflow. */
canvas { max-width:100% !important; }
.mada-chart-box { position:relative; min-height:260px; }

/* Booking compact hierarchy. */
.mada-booking-step { border:1px solid var(--mada-line); border-radius:16px; padding:14px; background:#fff; }
.mada-step-number { width:28px;height:28px;border-radius:999px;display:inline-flex;align-items:center;justify-content:center;background:var(--mada-soft);color:var(--mada-green-dark);font-weight:800;font-size:12px; }

/* =====================================================
   PAGE ENTER / LOGOUT TRANSITION
   ===================================================== */

body {
    animation: madaPageEnter .35s ease-out both;
}

body.mada-page-leave {
    opacity: 0;
    transform: translateY(-6px);
    transition:
        opacity .22s ease,
        transform .22s ease;
}

@keyframes madaPageEnter {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}
/* =========================================================
   MADA MODERN UI / MICRO INTERACTIONS
   Natural Agro-Tourism Style
========================================================= */


/* ---------------------------------------------------------
   PAGE ENTER
--------------------------------------------------------- */

@keyframes madaPageIn {

    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }

}


.app-page,
.page-content {
    animation:
        madaPageIn
        .38s
        cubic-bezier(.2,.8,.2,1)
        both;
}


/* ---------------------------------------------------------
   CARDS
--------------------------------------------------------- */

.card,
.stat-card,
.mada-card,
.destination-card {
    transition:
        transform .28s cubic-bezier(.2,.8,.2,1),
        box-shadow .28s ease,
        border-color .28s ease;
}


@media (hover:hover) {

    .card:hover,
    .stat-card:hover,
    .mada-card:hover,
    .destination-card:hover {

        transform:
            translateY(-4px);

        box-shadow:
            0 18px 38px
            rgba(15, 23, 42, .10);
    }

}


/* ---------------------------------------------------------
   BUTTON
--------------------------------------------------------- */

button,
.btn,
a[class*="bg-"] {

    transition:
        transform .18s ease,
        box-shadow .18s ease,
        filter .18s ease,
        background-color .18s ease;
}


@media (hover:hover) {

    button:hover,
    .btn:hover {

        transform:
            translateY(-1px);
    }

}


button:active,
.btn:active {

    transform:
        scale(.97);
}


/* ---------------------------------------------------------
   INPUT
--------------------------------------------------------- */

input,
select,
textarea {

    transition:
        border-color .2s ease,
        box-shadow .2s ease,
        background .2s ease;
}


input:focus,
select:focus,
textarea:focus {

    outline: none;

    box-shadow:
        0 0 0 4px
        rgba(16, 185, 129, .10);
}


/* ---------------------------------------------------------
   SIDEBAR MENU
--------------------------------------------------------- */

.app-sidebar-nav a,
.sidebar-nav a {

    position: relative;

    overflow: hidden;

    transition:
        transform .18s ease,
        background .18s ease,
        padding .18s ease;
}


@media (hover:hover) {

    .app-sidebar-nav a:hover,
    .sidebar-nav a:hover {

        transform:
            translateX(3px);
    }

}


/* ---------------------------------------------------------
   PROFILE / NOTIFICATION
--------------------------------------------------------- */

#notif-btn,
#admin-notif-btn {

    transition:
        transform .2s ease,
        box-shadow .2s ease,
        background .2s ease;
}


@media (hover:hover) {

    #notif-btn:hover,
    #admin-notif-btn:hover {

        transform:
            rotate(-7deg)
            scale(1.06);
    }

}


/* ---------------------------------------------------------
   NOTIFICATION BADGE
--------------------------------------------------------- */

#notif-badge:not(.hidden),
#admin-notif-badge:not(.d-none) {
    /*
       Pulse guna shadow sahaja.
       Jangan animate transform kerana ia boleh menolak badge terlalu tinggi
       dan merosakkan Bootstrap translate-middle / Tailwind positioning.
    */
    animation: madaNotifPulse 2s ease-in-out infinite;
}

@keyframes madaNotifPulse {
    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, .28);
    }

    50% {
        box-shadow: 0 0 0 5px rgba(239, 68, 68, 0);
    }
}


/* ---------------------------------------------------------
   IMAGE
--------------------------------------------------------- */

.mada-img-zoom img,
.destination-card img {

    transition:
        transform .5s
        cubic-bezier(.2,.8,.2,1);
}


@media (hover:hover) {

    .mada-img-zoom:hover img,
    .destination-card:hover img {

        transform:
            scale(1.045);
    }

}


/* ---------------------------------------------------------
   TABLE
--------------------------------------------------------- */

table tbody tr {

    transition:
        background .18s ease,
        transform .18s ease;
}


@media (hover:hover) {

    table tbody tr:hover {

        background:
            rgba(16,185,129,.035);
    }

}


/* ---------------------------------------------------------
   CHART
--------------------------------------------------------- */

canvas {

    max-width: 100% !important;
}


/* ---------------------------------------------------------
   MODAL
--------------------------------------------------------- */

.modal-content {

    border-radius: 20px;

    border: 0;

    box-shadow:
        0 25px 65px
        rgba(15, 23, 42, .20);
}


/* ---------------------------------------------------------
   CUSTOM MADA DIALOG
--------------------------------------------------------- */

#madaDialogBox {

    max-height:
        calc(100dvh - 32px);

    overflow-y: auto;
}


/* ---------------------------------------------------------
   MOBILE / TABLET RESPONSIVE
--------------------------------------------------------- */

@media (max-width: 767.98px) {

    /*
       Cards jangan rapat tepi phone.
    */
    .card,
    .stat-card,
    .mada-card {

        border-radius:
            15px;
    }


    /*
       Semua form control selesa ditekan.
    */
    input,
    select,
    textarea,
    button,
    .btn {

        min-height:
            42px;
    }


    /*
       Table boleh swipe kiri kanan.
    */
    .table-responsive,
    .mada-table-wrap {

        width: 100%;

        overflow-x: auto;

        -webkit-overflow-scrolling:
            touch;
    }


    /*
       Chart responsive.
    */
    .mada-chart-box {

        min-height:
            230px;
    }


    /*
       Bootstrap modal.
    */
    .modal-dialog {

        margin:
            12px;

        max-width:
            calc(100% - 24px);
    }

}


/* ---------------------------------------------------------
   SMALL PHONE
--------------------------------------------------------- */

@media (max-width: 480px) {

    #botPanel {

        position: fixed !important;

        left: 12px !important;
        right: 12px !important;

        bottom: 82px !important;

        width: auto !important;

        max-width: none !important;

        height:
            min(
                68dvh,
                520px
            ) !important;
    }


    /*
       Dialog logout tak terlebih screen.
    */
    #madaDialogBox {

        width:
            calc(100vw - 24px) !important;

        max-width:
            390px !important;
    }

}


/* ---------------------------------------------------------
   USER ACCESSIBILITY
--------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {

        animation-duration:
            .01ms !important;

        animation-iteration-count:
            1 !important;

        transition-duration:
            .01ms !important;

        scroll-behavior:
            auto !important;
    }

}

/* =========================================================
   AGROBOT — SENTIASA NAMPAK DALAM VIEWPORT
========================================================= */

#agroBot {
    position: fixed !important;
    right: 20px !important;
    bottom: 20px !important;
    z-index: 9999 !important;
    isolation: isolate;
}

#botToggle {
    position: relative;
    z-index: 2;
    box-shadow: 0 12px 30px rgba(5, 150, 105, .28);
}

#botPanel {
    z-index: 3;
}

@media (max-width: 767.98px) {
    #agroBot {
        right: 12px !important;
        bottom: calc(12px + env(safe-area-inset-bottom)) !important;
    }

    #botToggle {
        width: 54px !important;
        height: 54px !important;
    }
}
/* =========================================================
   VISITOR AGROBOT - FLOATING / STICKY ALL DEVICES
========================================================= */

#agroBot {
    position: fixed !important;
    right: 20px !important;
    bottom: 20px !important;
    top: auto !important;
    left: auto !important;
    margin: 0 !important;
    z-index: 999999 !important;
    transform: none !important;
}

/* Panel akan buka ke ATAS button */
#agroBot #botPanel {
    position: absolute !important;
    right: 0 !important;
    bottom: 68px !important;
    top: auto !important;
    left: auto !important;
    z-index: 1000000 !important;
}

/* Tablet */
@media (max-width: 767px) {
    #agroBot {
        right: 14px !important;
        bottom: calc(14px + env(safe-area-inset-bottom)) !important;
    }

    #agroBot #botToggle {
        width: 54px !important;
        height: 54px !important;
    }

    #agroBot #botPanel {
        right: 0 !important;
        bottom: 64px !important;
        width: calc(100vw - 28px) !important;
        max-width: 384px !important;
        max-height: calc(100vh - 100px) !important;
    }
}

/* Phone kecil */
@media (max-width: 480px) {
    #agroBot {
        right: 12px !important;
        bottom: calc(12px + env(safe-area-inset-bottom)) !important;
    }

    #agroBot #botPanel {
        position: fixed !important;
        left: 12px !important;
        right: 12px !important;
        bottom: calc(78px + env(safe-area-inset-bottom)) !important;
        top: auto !important;
        width: auto !important;
        max-width: none !important;
        height: min(68vh, 520px) !important;
    }
}

/* =========================================================
   FIX AGROBOT VISITOR - LOCK TO VIEWPORT
========================================================= */

/*
   Jangan bagi BODY jadi containing block untuk position:fixed.
   Body animation lama menggunakan transform dan menyebabkan
   AgroBot melekat pada hujung document, bukan screen.
*/
body {
    animation: none !important;
    transform: none !important;
}

/* AgroBot sentiasa ikut screen */
#agroBot {
    position: fixed !important;
    right: 20px !important;
    bottom: 20px !important;
    top: auto !important;
    left: auto !important;
    margin: 0 !important;
    z-index: 999999 !important;
}

/* Panel buka ke atas */
#agroBot #botPanel {
    position: absolute !important;
    right: 0 !important;
    bottom: 64px !important;
    top: auto !important;
    left: auto !important;
    z-index: 1000000 !important;
}

/* Tablet / phone */
@media (max-width: 767px) {

    #agroBot {
        right: 14px !important;
        bottom: calc(14px + env(safe-area-inset-bottom)) !important;
    }

    #agroBot #botPanel {
        right: 0 !important;
        bottom: 64px !important;
        width: calc(100vw - 28px) !important;
        max-width: 384px !important;
    }
}

/* Phone kecil */
@media (max-width: 480px) {

    #agroBot {
        right: 12px !important;
        bottom: calc(12px + env(safe-area-inset-bottom)) !important;
    }

    #agroBot #botPanel {
        position: fixed !important;
        left: 12px !important;
        right: 12px !important;
        bottom: calc(78px + env(safe-area-inset-bottom)) !important;
        width: auto !important;
        max-width: none !important;
        height: min(68vh, 520px) !important;
    }
}