/* ==========================================================================
   LegalPal - Main Stylesheet
   ========================================================================== */

/* Hero & Backgrounds */
/* Hero & Backgrounds */
.hero-background,
.hero-bg-default {
    background-image: url('https://imagedelivery.net/91g5n0eh9LtASHQiifhuEQ/b14cb835-bce7-4d83-f2f3-91e3f6c75400/public');
    background-size: cover;
    background-position: center;
}

@media (orientation: portrait) {
    .hero-background,
    .hero-bg-default {
        background-image: url('https://imagedelivery.net/91g5n0eh9LtASHQiifhuEQ/0a9c1bc1-93f1-4691-5a43-446185ab9700/public');
    }
}

.hero-bg-clients {
    background-image: url('https://imagedelivery.net/91g5n0eh9LtASHQiifhuEQ/be251cef-cce1-44c6-550d-89973d4c1f00/public');
    background-size: cover;
    background-position: center;
}

.hero-bg-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: opacity;
}


.hero-background.is-client {
    background-image: url('https://imagedelivery.net/91g5n0eh9LtASHQiifhuEQ/be251cef-cce1-44c6-550d-89973d4c1f00/public');
}

@media (orientation: portrait) {
    .hero-background {
        background-image: url('https://imagedelivery.net/91g5n0eh9LtASHQiifhuEQ/0a9c1bc1-93f1-4691-5a43-446185ab9700/public');
    }

    .hero-background.is-client {
        background-image: url('https://imagedelivery.net/91g5n0eh9LtASHQiifhuEQ/be251cef-cce1-44c6-550d-89973d4c1f00/public');
    }
}

/* Scrollbars */
.no-scrollbar::-webkit-scrollbar {
    display: none;
}

.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.scrollbar-visible::-webkit-scrollbar {
    display: none;
    height: 10px;
}

.scrollbar-visible:hover::-webkit-scrollbar,
.scrollbar-visible.dragging::-webkit-scrollbar {
    display: block;
    height: 10px;
}

.scrollbar-visible:hover::-webkit-scrollbar-track,
.scrollbar-visible.dragging::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.08);
}

.scrollbar-visible:hover::-webkit-scrollbar-thumb,
.scrollbar-visible.dragging::-webkit-scrollbar-thumb {
    background: rgba(0, 154, 228, 0.6);
    border-radius: 9999px;
}

.scrollbar-visible {
    scrollbar-width: none;
    scrollbar-color: rgba(0, 154, 228, 0.6) rgba(255, 255, 255, 0.08);
}

.scrollbar-visible:hover,
.scrollbar-visible.dragging {
    scrollbar-width: auto;
    scrollbar-color: rgba(0, 154, 228, 0.6) rgba(255, 255, 255, 0.08);
}

/* Header & Glassmorphism */
header {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.header-logo .cls-1 {
    fill: #ffffff;
    transition: fill 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

header.header-scrolled .header-logo .cls-1 {
    fill: #173124; /* primary color */
}

header.header-scrolled {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}

header.header-scrolled nav a {
    color: #424844;
}

/* Back to Top Button */
#back-to-top {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    cursor: pointer;
}

#back-to-top.visible {
    opacity: 1;
    pointer-events: auto;
}

#back-to-top:hover {
    transform: translateX(-50%) scale(1.1);
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

#back-to-top:focus {
    outline: 2px solid #009ae4;
    outline-offset: 2px;
}

/* Animations */
@keyframes appleFadeIn {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.apple-fade-in {
    animation: appleFadeIn 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    opacity: 0;
}

@keyframes fadeInFromRight {
    0% {
        opacity: 0;
        transform: translateX(30px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

.fade-in-from-right {
    opacity: 0;
    transform: translateX(30px);
    transition: opacity 1s cubic-bezier(0.25, 0.46, 0.45, 0.94), transform 1s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.fade-in-from-right.animate {
    opacity: 1;
    transform: translateX(0);
}

@keyframes fadeInUp {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    opacity: 0;
}

.fade-in-up.animate {
    animation: fadeInUp 1s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

html.chat-fullscreen-active,
body.chat-fullscreen-active {
    overflow: hidden !important;
    height: 100% !important;
    overscroll-behavior: none !important;
    touch-action: none !important;
}

body.menu-open {
    overflow: hidden;
    overscroll-behavior: contain;
}

/* Product Details Bottom Sheet Modal */
#product-details-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

#product-details-menu {
    height: 100dvh;
    height: 100vh;
    padding-top: max(4.5rem, env(safe-area-inset-top, 4.5rem));
    padding-bottom: max(1rem, env(safe-area-inset-bottom, 1rem));
    touch-action: pan-y;
}

#product-details-menu.visible {
    transform: translateY(0);
    pointer-events: auto;
}

#product-details-menu.is-dragging {
    transition: none !important;
    user-select: none !important;
    -webkit-user-select: none !important;
}

#product-details-menu.is-dragging * {
    user-select: none !important;
    -webkit-user-select: none !important;
}

#product-details-header {
    position: sticky;
    top: 0;
    z-index: 30;
    background-color: #ffffff;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

#product-details-drag-zone {
    touch-action: none;
}

#product-details-drag-handle {
    transition: background-color 0.2s ease, width 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.2s ease;
}

#product-details-header:hover #product-details-drag-handle {
    background-color: rgba(0, 0, 0, 0.4);
    width: 3.75rem;
}

#product-details-menu.is-dragging #product-details-drag-handle {
    background-color: #10b981;
    width: 4.25rem;
    transform: scale(1.08);
}

#product-details-card {
    max-height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom, 0.5rem));
}

#details-content-wrapper {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

#details-content-wrapper::-webkit-scrollbar {
    width: 6px;
}

#details-content-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

#details-content-wrapper::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 9999px;
}

/* Fullscreen Chat Animation */
@keyframes expand-fullscreen {
    to {
        clip-path: inset(0 0 0 0);
    }
}

@keyframes collapse-fullscreen {
    from {
        clip-path: inset(0 0 0 0);
    }
    to {
        clip-path: inset(45% 0 45% 0);
    }
}

/* Aurora Ambient Background */
.aurora-bg {
    background-color: #06130d;
    background-image:
        radial-gradient(ellipse 100% 70% at 50% -20%, rgba(74, 222, 128, 0.4), transparent 70%),
        radial-gradient(ellipse 80% 50% at 20% 30%, rgba(16, 185, 129, 0.3), transparent 60%),
        radial-gradient(ellipse 70% 60% at 85% 25%, rgba(0, 154, 228, 0.25), transparent 65%),
        radial-gradient(ellipse 60% 40% at 50% 60%, rgba(34, 197, 94, 0.15), transparent 50%),
        linear-gradient(180deg, #071710 0%, #05100b 100%);
    position: relative;
}

.aurora-ribbon {
    position: absolute;
    inset: -40%;
    pointer-events: none;
    background: radial-gradient(ellipse 70% 35% at 50% 40%, rgba(74, 222, 128, 0.25) 0%, rgba(16, 185, 129, 0.18) 35%, rgba(5, 150, 105, 0.08) 55%, transparent 75%);
    filter: blur(50px);
    opacity: 0.9;
    transform-origin: center;
    animation: auroraFloat 16s ease-in-out infinite alternate;
}

.aurora-ribbon-secondary {
    position: absolute;
    inset: -30%;
    pointer-events: none;
    background: radial-gradient(ellipse 60% 25% at 40% 30%, rgba(52, 211, 153, 0.28) 0%, rgba(0, 168, 232, 0.15) 40%, transparent 70%);
    filter: blur(40px);
    opacity: 0.8;
    animation: auroraFloat 20s ease-in-out infinite alternate-reverse;
}

@keyframes auroraFloat {
    0% {
        transform: rotate(0deg) scale(1) translate(0, 0);
    }
    50% {
        transform: rotate(3deg) scale(1.08) translate(-2%, 3%);
    }
    100% {
        transform: rotate(-2deg) scale(0.95) translate(3%, -2%);
    }
}

/* AI Chat Prompt & Fullscreen States */
#ai-chat-prompt.is-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    height: 100dvh !important;
    min-height: 100% !important;
    min-height: 100dvh !important;
    max-height: none !important;
    z-index: 99999 !important;
    background-color: #06130d !important;
    background-image:
        radial-gradient(ellipse 100% 70% at 50% -20%, rgba(74, 222, 128, 0.4), transparent 70%),
        radial-gradient(ellipse 80% 50% at 20% 30%, rgba(16, 185, 129, 0.3), transparent 60%),
        radial-gradient(ellipse 70% 60% at 85% 25%, rgba(0, 154, 228, 0.25), transparent 65%),
        linear-gradient(180deg, #071710 0%, #05100b 100%) !important;
    padding: 0 !important;
    color: #ffffff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: none;
    box-sizing: border-box !important;
    margin: 0 !important;
    transform: none !important;
}

#ai-chat-prompt.is-fullscreen #ai-chat-main-wrapper {
    height: var(--chat-visible-height, 100%) !important;
    max-height: var(--chat-visible-height, 100%) !important;
    width: 100% !important;
    max-width: 48rem !important;
    margin: 0 auto !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    align-items: center !important;
    min-height: 0 !important;
    flex: 0 0 auto !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    padding-top: max(0.75rem, env(safe-area-inset-top, 0.75rem)) !important;
    padding-left: max(0.75rem, env(safe-area-inset-left, 0.75rem)) !important;
    padding-right: max(0.75rem, env(safe-area-inset-right, 0.75rem)) !important;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0.75rem)) !important;
}

#fullscreen-chat-header {
    display: none;
    opacity: 0;
    transition: opacity 0.2s ease-in-out, padding 0.2s ease-in-out, margin 0.2s ease-in-out;
}

#ai-chat-prompt.is-fullscreen #fullscreen-chat-header {
    display: flex;
    opacity: 1;
    flex-shrink: 0;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    transition: margin 0.2s ease-in-out, padding 0.2s ease-in-out;
}

#ai-chat-prompt.is-fullscreen #chat-progress-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #ffffff;
    padding: 0.2rem 0.625rem;
    border-radius: 9999px;
    backdrop-filter: blur(8px);
}

/* =========================================================================
   Collapsed Header State (Active when message field is focused/selected)
   ========================================================================= */
#ai-chat-prompt.is-fullscreen.header-collapsed #fullscreen-chat-header {
    margin-bottom: 0.25rem !important;
    padding-bottom: 0.35rem !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12) !important;
}

#ai-chat-prompt.is-fullscreen.header-collapsed #fullscreen-chat-header .w-9.h-9,
#ai-chat-prompt.is-fullscreen.header-collapsed #fullscreen-chat-header h3,
#ai-chat-prompt.is-fullscreen.header-collapsed #fullscreen-chat-header p {
    display: none !important;
}

#ai-chat-prompt.is-fullscreen.header-collapsed #chat-progress-badge {
    display: inline-flex !important;
    align-items: center !important;
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.04em !important;
    text-transform: uppercase !important;
    background: rgba(255, 255, 255, 0.18) !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    color: #ffffff !important;
    padding: 0.3rem 0.75rem !important;
    border-radius: 9999px !important;
    backdrop-filter: blur(8px) !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important;
}

#ai-chat-prompt.is-fullscreen.header-collapsed #chat-progress-badge::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: #4ade80;
    border-radius: 50%;
    margin-right: 6px;
    box-shadow: 0 0 6px #4ade80;
}

#ai-chat-prompt.is-fullscreen.header-collapsed #close-chat-btn {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    border-radius: 9999px !important;
    background: rgba(255, 255, 255, 0.12) !important;
}

#ai-chat-prompt.is-fullscreen.header-collapsed #close-chat-btn span {
    font-size: 1.25rem !important;
}

#ai-chat-prompt.is-fullscreen #ai-chat-form {
    margin-top: auto !important;
    flex-shrink: 0 !important;
    width: 100% !important;
    max-width: 48rem !important;
    box-sizing: border-box !important;
}

#ai-chat-prompt.is-fullscreen .max-w-2xl {
    max-width: 48rem; /* 768px */
}

#ai-chat-title {
    transition: opacity 0.3s ease-out, max-height 0.5s ease-out, margin 0.5s ease-out, transform 0.5s ease-out;
    overflow: hidden;
}

#ai-chat-title.hidden {
    opacity: 0;
    max-height: 0px !important;
    margin-bottom: 0px !important;
    transform: scale(0.9);
}

#ai-chat-prompt.is-fullscreen #ai-chat-hero-content {
    display: none !important;
}

#ai-chat-prompt.is-fullscreen #ai-chat-messages {
    display: flex !important;
    flex-direction: column;
    justify-content: flex-start;
    gap: 0.75rem;
    flex: 1 1 0%;
    min-height: 0;
    width: 100%;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    padding: 0.5rem 0.25rem 0.75rem;
}

#ai-chat-prompt.is-fullscreen #ai-chat-messages > :first-child {
    margin-top: auto !important;
}

#ai-chat-prompt:not(.is-fullscreen) #ai-chat-messages {
    display: none !important;
}

#ai-chat-resume-content {
    display: none;
}

#ai-chat-prompt.has-active-chat:not(.is-fullscreen) #ai-chat-hero-content {
    display: none !important;
}

#ai-chat-prompt.has-active-chat:not(.is-fullscreen) #ai-chat-resume-content {
    display: flex !important;
}

#ai-chat-prompt.is-fullscreen #ai-chat-resume-content {
    display: none !important;
}

/* AI Chat Textarea styling */
#ai-chat-input {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    resize: none !important;
    line-height: 1.45;
    max-height: 140px;
    min-height: 24px;
    min-width: 0 !important;
    font-size: 16px !important; /* CRITICAL: Prevents iOS WebKit auto-zoom */
    -webkit-text-size-adjust: 100%;
    -webkit-appearance: none;
    appearance: none;
    scrollbar-width: thin;
}

#ai-chat-input::-webkit-scrollbar {
    width: 4px;
}

#ai-chat-input::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

/* Collapse Disclaimer inside Fullscreen Active Chat */
#ai-chat-prompt.is-fullscreen #ai-chat-confidentiality {
    display: none !important;
}

/* Mobile chat styles */
@media (max-width: 768px) {
    #ai-chat-prompt.is-fullscreen {
        padding: 0 !important;
    }

    #ai-chat-prompt.is-fullscreen #ai-chat-main-wrapper {
        padding-top: max(0.5rem, env(safe-area-inset-top, 0.5rem)) !important;
        padding-left: max(0.5rem, env(safe-area-inset-left, 0.5rem)) !important;
        padding-right: max(0.5rem, env(safe-area-inset-right, 0.5rem)) !important;
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom, 0.5rem)) !important;
    }

    #ai-chat-prompt.is-fullscreen:not(.header-collapsed) #fullscreen-chat-header {
        margin-bottom: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }

    #ai-chat-prompt.is-fullscreen:not(.header-collapsed) #fullscreen-chat-header .w-9.h-9 {
        display: flex !important;
    }

    #ai-chat-prompt.is-fullscreen:not(.header-collapsed) #fullscreen-chat-header h3 {
        display: block !important;
        font-size: 1.125rem !important;
    }

    #ai-chat-prompt.is-fullscreen:not(.header-collapsed) #fullscreen-chat-header p {
        display: flex !important;
    }

    #ai-chat-prompt.is-fullscreen #ai-chat-messages {
        margin-bottom: 0.375rem;
    }

    .user-message-bubble > div,
    .assistant-message-bubble > div {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
}

/* Speech Bubble */
.speech-bubble {
    position: relative;
    border-radius: 1.5rem 1.5rem 1.5rem 0.25rem;
}

.speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 28px;
    border-width: 8px 8px 0 0;
    border-style: solid;
    border-color: #ffffff transparent transparent transparent;
}

/* Scenario Carousel */
.scenario-carousel-track {
    display: flex;
    transition: transform 0.5s cubic-bezier(0.25, 1, 0.5, 1);
}

.scenario-slide {
    flex: 0 0 100%;
    min-width: 100%;
}

.carousel-dot {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.carousel-dot.active {
    width: 2rem !important;
    background-color: #173124 !important;
}

/* Message Bubbles */
.user-message-bubble {
    display: flex;
    justify-content: flex-end;
    width: 100%;
    margin-bottom: 0;
}

.user-message-bubble > div {
    background-color: #006591; /* secondary */
    color: #ffffff; /* on-secondary */
    padding: 0.75rem 1.25rem;
    border-radius: 1.5rem 1.5rem 0.25rem 1.5rem;
    max-width: 80%;
    text-align: left;
    font-size: 0.95rem;
    line-height: 1.45;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    animation: fadeInUp 0.28s cubic-bezier(0.16, 1, 0.3, 1) both;
    overflow-wrap: break-word;
    word-break: break-word;
}

.assistant-message-bubble {
    display: flex;
    justify-content: flex-start;
    width: 100%;
    margin-bottom: 0;
}

.assistant-message-bubble > div {
    background-color: #ffffff;
    color: #191c1d;
    border: 1px solid rgba(194, 200, 194, 0.5);
    padding: 0.75rem 1.25rem;
    border-radius: 1.5rem 1.5rem 1.5rem 0.25rem;
    max-width: 85%;
    text-align: left;
    font-size: 0.95rem;
    line-height: 1.45;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
    animation: fadeInUp 0.32s cubic-bezier(0.16, 1, 0.3, 1) both;
    overflow-wrap: break-word;
    word-break: break-word;
}

.intake-summary-card {
    background-color: #ffffff;
    color: #191c1d;
    border-radius: 1.5rem;
    padding: 1.25rem;
    border: 1px solid rgba(194, 200, 194, 0.6);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-wrap: break-word;
    word-break: break-word;
}

@keyframes fadeInUp {
    0% {
        opacity: 0;
        transform: translateY(16px) scale(0.98);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Typing Indicator Animation */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0.65rem 1rem !important;
    border-radius: 1.25rem !important;
    min-height: 2.25rem;
    background-color: #ffffff !important;
    border: 1px solid rgba(194, 200, 194, 0.5) !important;
}

.typing-dot {
    width: 7px;
    height: 7px;
    background-color: #006591;
    border-radius: 50%;
    display: inline-block;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
.typing-dot:nth-child(3) { animation-delay: 0s; }

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.35;
    }
    40% {
        transform: scale(1.15);
        opacity: 1;
    }
}

/* Intake Case File Summary Card */
.intake-summary-card {
    width: 100%;
    max-width: 480px;
    border-radius: 1.25rem;
    background: #ffffff;
    color: #191c1d;
}

/* Content Toggles */
#lawyer-content {
    transition: opacity 0.4s ease-in-out;
}

#lawyer-content.hidden {
    display: none !important;
}

#client-content {
    transition: opacity 0.4s ease-in-out;
}

#client-content.hidden {
    display: none !important;
}

