* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --color-primary: #000000;
    --browse-width: 500px;
}

body {
    /* font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; */
    font-family: "Gotham SSm A","Gotham SSm B",Montserrat,sans-serif;
    line-height: 1.5;
    /* background: black; */
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: #333;
}

/* fallback */
@font-face {
  font-family: 'Material Symbols Outlined';
  font-style: normal;
  font-weight: 400;
  src: url(https://fonts.gstatic.com/s/materialsymbolsoutlined/v303/kJF1BvYX7BgnkSrUwT8OhrdQw4oELdPIeeII9v6oDMzByHX9rA6RzaxHMPdY43zj-jCxv3fzvRNU22ZXGJpEpjC_1v-p_4MrImHCIJIZrDCvHOej.woff2) format('woff2');
}

.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
}

/* .callInactive .controls {
            margin: 0;
            position: absolute;
            width: calc(100% - 80px);
            top: 50%;
            transform: translate3d(0, -50%, 0);
        }

        .callInactive .chat-window,
        .callInactive .status {
            display: none;
            height: 0;
        }

        .container.callInactive {
            height: 140px;;
        } */

.callActive .chat-window {
    height: 50vh;
    padding: 20px;
    /* margin-bottom: 20px; */
}

/* .callActive .controls {
    margin-top: 20px;
} */

.container {
    position: absolute;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    height: auto;
    width: calc(100% - 40px);
    max-width: 800px;
    padding: 40px;
    top: 47%;
    margin-top: 20px;
    transform: translate3d(0, -50%, 0);
    -webkit-transform: translate3d(0, -50%, 0);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: fadeIn 0.5s ease-out;
    transition: all 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
        -webkit-transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(-50%);
        -webkit-transform: translateY(-50%);
    }
}

.hide {
    display: none;
}

h1 {
    text-align: center;
    color: #667eea;
    margin-bottom: 10px;
    font-size: 2em;
    font-weight: 700;
}

.subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
    font-size: 0.9em;
}

.config-section {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;
}

.config-group {
    margin-bottom: 15px;
}

.config-group:last-child {
    margin-bottom: 0;
}

label {
    display: block;
    margin-bottom: 5px;
    color: #555;
    font-weight: 500;
    font-size: 0.9em;
}

input,
select {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.95em;
    transition: all 0.3s ease;
    background: white;
}

input:focus,
select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chat-window {
    position: relative;
    z-index: 1;
    background: #f8f9fa;
    border-radius: 12px;
    height: 0;
    overflow-y: auto;
    padding: 0;
    margin-bottom: 0;
    scroll-behavior: smooth;
    transition: all 0.3s ease-out;
}

.message {
    margin-bottom: 15px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
        -webkit-transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
        -webkit-transform: translateX(0);
    }
}

.message.user {
    text-align: right;
}

.message.assistant {
    text-align: left;
}

.message-content {
    display: inline-block;
    padding: 20px 25px;
    border-radius: 18px;
    max-width: 90%;
    word-wrap: break-word;
}

.message.user .message-content {
    background: black;
    color: white;
}

.message.assistant .message-content {
    background: white;
    color: #333;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.controls {
    display: flex;
    gap: 15px;
    margin-bottom: 0;
    flex-direction: column;
}

/* When container has textMode class show text form and hide mic button */
.container.textMode .text-form {
    /* display: flex !important; */
    transform: rotateX(0deg) !important;
    -webkit-transform: rotateX(0deg) !important;
}

.container.textMode .mic-button {
    /* display: none !important; */
    transform: rotateX(180deg);
    -webkit-transform: rotateX(180deg);
}

.text-form {
    /* display: none !important; */
    position: absolute;
    width: calc(100% - 80px);
    position: absolute;
    width: calc(100% - 80px);
    transform: rotateX(180deg);
    -webkit-transform: rotateX(180deg);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transition: transform 0.3s ease-out;
}

/* style for the mode switch */
.mode-switch-wrap {
    display: flex;
    justify-content: center;
}

.mode-switch {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    border-radius: 20px;
    background: #f1f1f1;
    color: #333;
    border: 1px solid #e0e0e0;
    cursor: pointer;
    font-weight: 600;
    height: 41px;
    transition: left 0.12s ease, transform 0.12s ease;
}

.mode-highlight {
  /* layout */
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;

  /* tailwind m-1 -> 0.25rem */
  margin: 0.25rem;

  /* w-[calc(50%-0.25rem)] */
  width: calc(50% - 0.25rem);

  /* h-8 -> 2rem (Tailwind spacing scale) */
  height: 2rem;

  /* background & shape */
  background-color: var(--color-primary); /* replace with your color, e.g. #0ea5e9 */
  border-radius: 9999px; /* rounded-full */

  /* transform & transition */
  transform: translateX(0); /* translate-x-0 */
  -webkit-transform: translateX(0); /* translate-x-0 */
  transition: transform 0.3s ease-in-out; /* transition-transform duration-300 ease-in-out */

  /* (optional) make sizing predictable */
  box-sizing: border-box;
}

.mode-switch button {
    background: transparent;
}

.call-mode {
  position: relative;          /* relative */
  z-index: 10;                 /* z-10 */
  flex: 1;                     /* flex-1 */
  height: 100%;                /* h-full */
  display: flex;               /* flex */
  align-items: center;         /* items-center */
  justify-content: center;     /* justify-center */
  color: #ffffff;              /* text-white */
  transition: color 0.3s ease-in-out;
}

.text-mode {
  position: relative;          /* relative */
  z-index: 10;                 /* z-10 */
  flex: 1;                     /* flex-1 */
  height: 100%;                /* h-full */
  display: flex;               /* flex */
  align-items: center;         /* items-center */
  justify-content: center;     /* justify-center */
  color: #000000;              /* text-slate-700 */
  transition: color 0.3s ease-in-out;
}
.mode-switch[aria-pressed="true"] .mode-highlight {
    transform: translateX(100%);
    -webkit-transform: translateX(100%);
}
.mode-switch[aria-pressed="true"] .text-mode{
    color: white;
}
.mode-switch[aria-pressed="true"] .call-mode{
    color: black;
}

button {
    flex: 1;
    padding: 15px;
    border: none;
    border-radius: 12px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: none;
    letter-spacing: 0.5px;
}

.mic-button, .send-button {
    background: black;
    color: white;
    position: relative;
    /* overflow: hidden; */
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transition: transform 0.3s ease-out;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

/* .mic-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(125, 125, 125, 0.3);
} */

.mic-button:disabled, .send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.mic-button.listening, .send-button.sending {
    animation: pulse 1.5s infinite;
}

.mic-button:before,
.mic-button:after,
.send-button:before,
.send-button:after {
    content: '';
    position: absolute;
    left: -1px;
    top: -1px;
    background: linear-gradient(45deg, #fb0094, #0000ff, #00ff00, #ffff00, #ff0000, #fb0094,
            #0000ff, #00ff00, #ffff00, #ff0000);
    background-size: 300%;
    width: calc(100% + 2px);
    height: calc(100% + 2px);
    z-index: -1;
    animation: steam 20s linear infinite;
    border-radius: 12px;
}

@keyframes steam {
    0% {
        background-position: 0 0;
    }

    50% {
        background-position: 300% 0;
    }

    100% {
        background-position: 0 0;
    }
}

.mic-button:after, .send-button:after {
    filter: blur(2px);
}

@keyframes pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.7);
    }

    50% {
        box-shadow: 0 0 0 15px rgba(102, 126, 234, 0);
    }
}

.clear-button {
    background: #f44336;
    color: white;
}

.clear-button:hover {
    background: #da190b;
    transform: translateY(-2px);
    -webkit-transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(244, 67, 54, 0.3);
}

.callActive .status {
    display: flex;
}

.status {
    position: relative;
    top: -40px;
    display: none;
    text-align: center;
    padding: 10px;
    padding-top: 20px;
    border-radius: 8px;
    font-size: 0.9em;
    height: 40px;
    align-items: center;
    justify-content: center;
    /* transition: all 0.3s ease; */
}

.status.idle {
    background: #f1f1f1;
    color: gray;
}

.status.listening {
    background: #e8f5e9;
    color: #388e3c;
    font-weight: 600;
}

.status.processing {
    background: #fff3e0;
    color: #f57c00;
}

.status.error {
    background: #ffebee;
    color: #c62828;
}

.status.speaking {
    background: #f3e5f5;
    color: #7b1fa2;
}

.voice-settings {
    display: none;
    /* display: grid; */
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.loading-dots {
    display: inline-block;
}

.loading-dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0% {
        content: '';
    }

    25% {
        content: '.';
    }

    50% {
        content: '..';
    }

    75% {
        content: '...';
    }
}

.error-message {
    background: #ffebee;
    color: #c62828;
    padding: 10px;
    border-radius: 8px;
    margin-top: 10px;
    font-size: 0.9em;
}

@media (max-width: 600px) {
    .container {
        padding: 25px;
    }

    .voice-settings {
        grid-template-columns: 1fr;
    }
}

.logo {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translate3d(-50%, -250%, 0) scale(1.2);
    -webkit-transform: translate3d(-50%, -250%, 0) scale(1.2);
    transform-origin: center center;
    -webkit-transform-origin: center center;
    background: #000000;
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center; /* ensure img is centered */
    border-radius: 30px;
    padding: 8px;
    border-top: 2px solid transparent;
    z-index: 1;
    transition: transform 0.3s ease-out;
    overflow: hidden;
}

.logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.callActive .logo {
    /* animation: slideLogo 0.3s ease-out forwards; */
    transform: translate3d(-50%, -60%, 0) scale(1);
    -webkit-transform: translate3d(-50%, -60%, 0) scale(1);
}

/* @keyframes slideLogo {
    to {
        transform: translate3d(-50%, -50%, 0) scale(1);
    }
} */

/* WebKit / iOS specific fixes */
html, body {
    -webkit-text-size-adjust: 100%; /* prevent font autosizing on iOS */
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

/* WebKit / iOS specific fixes */
html, body {
    -webkit-text-size-adjust: 100%; /* prevent font autosizing on iOS */
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

/* improve momentum scrolling for chat on iOS */
.chat-window {
    -webkit-overflow-scrolling: touch;
}

/* prevent accidental selection on interactive buttons */
button, .mode-switch {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* nicer scrollbars on WebKit */
.chat-window::-webkit-scrollbar {
    width: 8px;
}

.chat-window::-webkit-scrollbar-track {
    background: transparent;
}

.chat-window::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.12);
    border-radius: 8px;
}

audio, video {
    display: inline-block;
    max-width: 100%;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.browsemode .container {
    top: 50%;
    right: 0;
    height: 100%;
    width: var(--browse-width);
    margin: 0;
    border-radius: 0;
    padding: 70px 20px 20px;
    border-left: solid 1px lightgray;
}
.browsemode .container .logo {
    opacity: 0;
}
.browsemode .container .chat-window {
    margin-bottom: 30px;
    height: calc(100% - 180px);
}
.browsemode .text-form {
    width: calc(100% - 40px);
}
.browsemode .mode-switch {
    right: auto;
}
.browsemode iframe {
    position: absolute;
    display: block;
    width: calc(100% - var(--browse-width));
    height: 100%;
    border: none;
    top: 0;
    left: 0;
}

.browse-close-button {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 80;
    display: none; /* hidden by default; .hide also used */
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: rgba(255,255,255,0.95);
    border: 1px solid rgba(0,0,0,0.06);
    color: var(--color-primary, #000);
    height: 40px;
    width: 40px;
    border-radius: 10px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
    cursor: pointer;
    font-size: 20px;
}

/* show when in browsemode */
.browsemode .browse-close-button {
    display: flex;
}

/* small responsive tweak */
@media (max-width: 900px) {
    .browsemode .browse-close-button {
        top: 10px;
        right: 10px;
    }
}

.browse-resizer {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 22px; /* bigger hit area for easier dragging */
    left: calc(100% - var(--browse-width) - 11px); /* center on seam (half of width) */
    z-index: 999;
    cursor: ew-resize;
    display: none;
    background: transparent; /* keep mostly transparent */
    touch-action: none; /* required for consistent pointer events on touch */
    -webkit-user-select: none;
    user-select: none;
}

/* thin visible handle centered inside the larger hit area */
.browse-resizer::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 3px;           /* visible handle width */
    height: 48px;         /* handle height */
    background: rgba(0,0,0,0.12);
    border-radius: 3px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
    pointer-events: none; /* don't block pointer events from the parent */
    transition: background 0.12s ease, transform 0.12s ease;
    opacity: 0.9;
}

.browse-resizer:hover::before,
.document-resizing .browse-resizer::before {
    background: rgba(0,0,0,0.18);
    transform: translate(-50%, -50%) scaleX(1.05);
}

/* show resizer in browsemode */
.browsemode .browse-resizer {
    display: block;
}

/* Optional: when dragging add a body class to disable selection globally */
.document-resizing, .document-resizing * {
    -webkit-user-select: none !important;
    user-select: none !important;
    -webkit-touch-callout: none !important;
}

.product-item, .contact {
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 15px;
    margin: 10px 0;
    display: flex;
    flex-direction: column;
    align-items: baseline;
    gap: 15px;
    background: white;
    transition: box-shadow 0.3s ease;
}
.product-item img, .contact img, .message-content img {
    position: relative;
    left: 50%;
    transform: translateX(-50%);
    max-width: 100%;
}
/* Ensure links inside product items wrap and do not force overflow */
.product-item a,
.product-item .url,
.contact a,
.contact .url {
    display: block;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
    text-decoration: underline;
}

/* .contact img, .message-content img {
    width: 100%;
} */

.source-container {
    display: flex;
    flex-direction: column;
    font-size: small;
}

/* Hide individual source buttons by default; show when expanded */
.source-container .source-button {
    display: none;
    margin-top: 8px;
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    background: white;
    border-radius: 8px;
    text-align: left;
    cursor: pointer;
}
.source-container.expanded .source-button {
    display: block;
}

.expand-sources-button {
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
    background: #f6f7fb;
    border-radius: 8px;
    cursor: pointer;
}

/* Source popup modal */
.source-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}
.source-popup {
    background: #fff;
    color: #111;
    border-radius: 12px;
    max-width: 900px;
    width: 100%;
    max-height: 80vh;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}
.source-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    background: linear-gradient(0deg, rgba(0,0,0,0.02), rgba(0,0,0,0));
}
.source-popup-title {
    font-weight: 700;
    font-size: 1rem;
}
.source-popup-close {
    background: transparent;
    border: none;
    font-size: 1.05rem;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    color: #333;
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.source-popup-body {
    padding: 16px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, 'Roboto Mono', 'Courier New', monospace;
    font-size: 0.95rem;
    line-height: 1.45;
    background: #fafafa;
    margin: 0;
}

@media (max-width: 600px) {
    .source-popup { max-height: 90vh; border-radius: 10px; }
    .source-popup-body { font-size: 0.9rem; padding: 12px; }
}