/* SailGuru fullscreen application layout */

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
}

body[data-app] {
    overflow: hidden;
    background: #063b5d;
}

body[data-app] #app {
    width: 100%;
    height: 100dvh;
    min-height: 100vh;

    background-image: url("assets/background.jpg");
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;

    display: flex;
    flex-direction: column;
}

/* ---------- HEADER ---------- */

body[data-app] header.topbar {
    flex: 0 0 auto;
    background: #fff;

    padding:
        max(16px, env(safe-area-inset-top))
        28px
        16px;

    min-height: 82px;
    box-sizing: border-box;
}

body[data-app] .topbar-logo {
    width: 52px;
    flex-basis: 52px;
}

body[data-app] .topbar-name {
    color: #272b3d;
    letter-spacing: 0;
    font-size: 23px;
    line-height: 1;
    text-transform: none;
}

body[data-app] .topbar-tagline {
    color: #272b3d;
    letter-spacing: 0;
    font-size: 13px;
    margin-top: 5px;
}

body[data-app] .topbar-reset::before {
    color: #272b3d;
}

body[data-app] .header-mask {
    display: none;
}

/* ---------- SCROLL / CONTENT ---------- */

body[data-app] #chat-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;

    box-sizing: border-box;

    padding:
        42px
        20px
        max(32px, env(safe-area-inset-bottom));
}

/*
 * Landbot-like application geometry:
 * fullscreen background, bounded conversation.
 */
body[data-app] #chat,
body[data-app] #controls {
    width: min(100%, 640px);
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}

/* ---------- BUBBLES ---------- */

body[data-app] .bubble.bot,
body[data-app] .bot {
    color: #2d3040;
    background: #fff;
    border: 0;
    border-radius: 11px;
    border-bottom-left-radius: 3px;
}

body[data-app] .bubble.user,
body[data-app] .user {
    background: rgba(255,255,255,.94);
    color: #2d3040;
}

body[data-app] .bot-avatar {
    border-radius: 50%;
    object-fit: cover;
}

/* ---------- CHOICES ---------- */

body[data-app] #controls {
    margin-top: 10px;
}

body[data-app] #controls button:not(.restart):not(.sailbot-restart) {
    min-height: 52px;
    margin: 4px 0;
    padding: 12px 18px;

    border: 2px solid rgba(255,255,255,.95);
    border-radius: 28px;

    background: #29cf87;
    color: #fff;

    box-shadow:
        0 2px 5px rgba(0,0,0,.14),
        inset 0 1px 0 rgba(255,255,255,.18);

    font-size: 15px;
    font-weight: 400;
    line-height: 1.2;
    text-transform: none;
}

body[data-app] #controls button:not(.restart):not(.sailbot-restart):hover {
    background: #22c67e;
}

body[data-app] #controls button:not(.restart):not(.sailbot-restart):active {
    transform: translateY(1px);
    background: #1fba76;
}

/* ---------- DESKTOP ---------- */

@media (min-width: 769px) {

    body[data-app] #chat-scroll {
        padding-top: 50px;
    }

    /*
     * Controls may internally use a two-column grid.
     * It remains constrained by the same 640px container.
     */
    body[data-app] #controls button:not(.restart):not(.sailbot-restart) {
        width: 100%;
    }
}

/* ---------- MOBILE ---------- */

@media (max-width: 768px) {

    body[data-app] header.topbar {
        min-height: 78px;

        padding:
            max(13px, env(safe-area-inset-top))
            16px
            13px;
    }

    body[data-app] .topbar-logo {
        width: 46px;
        flex-basis: 46px;
    }

    body[data-app] .topbar-name {
        font-size: 21px;
    }

    body[data-app] .topbar-tagline {
        font-size: 12px;
    }

    body[data-app] #chat-scroll {
        padding:
            26px
            15px
            max(24px, env(safe-area-inset-bottom));
    }

    body[data-app] #chat,
    body[data-app] #controls {
        width: 100%;
        max-width: none;
    }

    body[data-app] #controls button:not(.restart):not(.sailbot-restart) {
        min-height: 54px;
        width: 100%;
    }
}

/* Final spacing tune against original Landbot */

body[data-app="sail-anchor"] .bubble {
    font-size: 14px;
    line-height: 1.42;
}

body[data-app="sail-anchor"] .bubble.bot,
body[data-app="sail-anchor"] .bot {
    padding: 15px 18px;
}

body[data-app="sail-anchor"] .message-wrapper {
    margin-bottom: 10px;
}

body[data-app="sail-anchor"] #controls {
    margin-top: 14px;
    gap: 10px;
}

body[data-app="sail-anchor"] #controls button:not(.restart):not(.sailbot-restart) {
    padding: 15px 20px;
}

/* User answer bubble: Landbot-style SailGuru */
body[data-app="sail-anchor"] .bubble.user {
  width: auto;
  max-width: 70%;
  margin-left: auto;
  margin-right: 0;

  padding: 13px 22px;

  background: #29cf87;
  color: #ffffff;

  border: 0;
  border-radius: 18px;
  border-bottom-right-radius: 3px;

  font-size: 14px;
  line-height: 1.25;
  text-align: center;

  box-shadow: 0 2px 5px rgba(0,0,0,.12);
}

/* User message has no bot avatar */
body[data-app="sail-anchor"] .message-wrapper:has(.bubble.user) {
  justify-content: flex-end;
}

body[data-app="sail-anchor"] .message-wrapper:has(.bubble.user) .bot-avatar {
  display: none;
}

/* User bubble: velikost podle obsahu */
body[data-app="sail-anchor"] .bubble.user {
  width: fit-content;
  min-width: 90px;
  max-width: 70%;
  padding: 13px 24px;
  margin-left: auto;
  margin-right: 0;
}

/* WordPress emoji */
body[data-app="sail-anchor"] img.emoji {
    display: inline-block !important;
    width: 1em !important;
    height: 1em !important;
    min-width: 0 !important;
    max-width: none !important;
    margin: 0 .08em !important;
    padding: 0 !important;
    border: 0 !important;
    vertical-align: -0.12em !important;
    object-fit: contain !important;
}
