:root {
  --primary: #003060;
  --secondary: #64748b;
  --accent: #055c9d;
  --accent-light: #0e86d4;
  --surface: #0766c5;
  --text: #ffffff;
  --border: #e2e8f0;

  /* Base styles */
  html,
  body,
  #outer-shell,
  #middle-section,
  #app {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    font-size: 14px;
  }

  .welcome-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 8px;
    text-align: center;
    padding: 0 16px;
    /* background-color: var(--surface); */
    backdrop-filter: blur(25px);
  }

  .welcome-panel h2,
  .welcome-panel p {
    margin: 0;
    line-height: 1.3;
  }

  .welcome-panel h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
  }

  .welcome-panel p {
    font-size: 0.875rem;
    color: var(--text);
  }

  .welcome-logo {
    max-height: 80px;
    width: auto;
    display: block;
    margin: 0 auto 12px;
  }

  .chat-collapsed .top-bar,
  .chat-collapsed .left-bar,
  .chat-collapsed .right-bar,
  .chat-collapsed #dynamic-pane,
  .chat-collapsed .bottom-bar {
    display: none !important;
  }

  #outer-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
  }

  .top-bar,
  .bottom-bar {
    height: 3vh;
    background-color: var(--surface);
    display: flex;
    align-items: center;
    padding: 0 20px;
  }

  .bottom-bar {
    border-bottom: none;
  }

  #middle-section {
    flex: 1;
    display: flex;
    flex-direction: row;
  }

  .left-bar,
  .right-bar {
    width: 3vw;
    background-color: var(--surface);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 10px;
  }

  .right-bar {
    border-right: none;
  }

  #app {
    display: flex;
    flex: 1;
    flex-direction: row;
    position: relative;
  }

  #resizer {
    width: 5px;
    cursor: ew-resize;
    background-color: var(--border);
  }

  #chat-pane {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-height: 100vh;
    width: 35%;
    min-width: 100px;
    /* background-color: var(--surface); */
    border-right: 1px solid var(--border);
    transition: width 0.3s ease;
  }

  .chat-collapsed #chat-pane {
    width: 100% !important;
  }

  #dynamic-pane {
    flex: 1;
    background-color: var(--surface);
    padding: 20px;
    overflow-y: auto;
    transition: width 0.3s ease;
  }

  #chat-pane,
  #dynamic-pane {
    transition: width 0.3s ease, display 0.3s ease;
  }

  .chat-header {
    background-color: var(--primary);
    color: var(--text);
    padding: 10px 14px;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* border-top-right-radius: 12px; */
    border-bottom: 1px solid var(--border);
    transition: background-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    backdrop-filter: blur(25px);
  }

  .chat-header:hover {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  }

  .chat-header-title {
    padding-left: 8px;
  }

  .chat-header-controls {
    display: flex;
    margin-left: auto;
    padding-right: 8px;
  }

  .chat-header button {
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 18px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    cursor: pointer;
  }

  .chat-header-controls button {
    margin-left: 6px;
  }

  .chat-header button:hover {
    background-color: var(--surface);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  }

  .chat-modal body,
  .chat-modal #outer-shell {
    position: fixed;
    background: white;
    border-radius: 16px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.4);
    z-index: 1000000;
    height: auto;
    width: auto;
    overflow: hidden;
  }

  .chat-modal #outer-shell {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
  }

  .chat-modal .top-bar,
  .chat-modal .bottom-bar,
  .chat-modal .left-bar,
  .chat-modal .right-bar {
    display: none !important;
  }

  .chat-modal #middle-section {
    flex: 1;
    display: flex;
    flex-direction: row;
  }

  .chat-modal #chat-pane {
    width: 35% !important;
    min-width: 400px;
    display: flex;
  }

  .chat-modal #dynamic-pane {
    width: 65% !important;
    display: block !important;
    padding: 20px;
    background-color: var(--surface);
  }

  .chat-modal #app {
    display: flex;
    flex-direction: row;
    flex: 1;
  }

  .chat-modal #resizer {
    width: 5px;
    background-color: var(--border);
    cursor: ew-resize;
  }

  .chat-modal .top-bar,
  .chat-modal .left-bar,
  .chat-modal .right-bar,
  .chat-modal .bottom-bar {
    display: flex !important;
  }

  .chat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    /* background-color: var(--surface); */
    backdrop-filter: blur(25px);
    padding-right: 5px;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  html.chat-modal .chat-messages {
    padding-bottom: 50px;
  }

  .chat-messages::-webkit-scrollbar {
    display: none;
  }

  .chat-input {
    border-top: 1px solid var(--border);
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
    bottom: 0px;
    position: sticky;
    background-color: transparent;
    backdrop-filter: blur(25px);
  }

  .chat-input textarea,
  .chat-input input {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 5px;
    resize: none;
    overflow: hidden;
    height: 25px;
    line-height: 20px;
    font-family: inherit;
    font-size: 1rem;
  }

  .chat-input button {
    background-color: var(--accent);
    color: var(--text);
    border: none;
    padding: 10px 16px;
    border-radius: 5px;
    cursor: pointer;
  }

  .chat-input button:hover {
    background-color: var(--surface);
  }

  .chat-input button:focus-visible {
    background-color: var(--surface);
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  .collapse-button {
    background: transparent;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
  }

  #send-button,
  #file-upload-button,
  #mic-button {
    /* background-color: var(--surface); */
    background: transparent;
    border: none;
    padding: 10px;
    border-radius: 5px;
    cursor: pointer;
  }

  #send-button:hover,
  #file-upload-button:hover,
  #mic-button:hover {
    background-color: var(--surface);
  }

  #send-button {
    color: var(--text);
  }

  #recording-indicator {
    color: red;
    font-size: 18px;
    margin-left: 8px;
    animation: blink 1s steps(2, start) infinite;
  }

  @keyframes blink {
    to {
      visibility: hidden;
    }
  }

  .input-wrapper {
    position: relative;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
  }

  .input-wrapper input {
    width: 100%;
    box-sizing: border-box;
  }

  .wave {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 4px;
    width: 100%;
    pointer-events: none;
    background: linear-gradient(90deg, var(--accent) 25%, transparent 25%, transparent 50%, var(--accent) 50%, var(--accent) 75%, transparent 75%);
    background-size: 200% 100%;
    animation: waveAnim 2.5s linear infinite;
    border-radius: 2px;
    z-index: 10;
  }

  @keyframes waveAnim {
    from {
      background-position: 200% 0;
    }

    to {
      background-position: -200% 0;
    }
  }

  #dynamic-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  #dynamic-pane.hidden,
  #chat-pane.hidden {
    display: none !important;
  }

  #chat-pane.expanded,
  #dynamic-pane.expanded {
    flex: 1 !important;
  }

  #dynamic-browser {
    flex: 1;
    width: 100%;
    height: 100%;
    border: none;
  }

  /* ---------- AVATAR ---------- */
  .message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    margin-right: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
  }

  .message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
  .message-avatar span {
    line-height: 1;
  }

  /* ---------- MESSAGE BUBBLES ---------- */
  .message-container {
    margin-bottom: 8px;
    word-wrap: break-word;
  }

  /* Bot (incoming) */
  .incoming-message {
    background: var(--secondary);
    color: var(--text);
    border-radius: 0 12px 12px 12px;
    padding-left: 20px;
    align-self: flex-start;
    max-width: 75%;
  }

  /* User (outgoing) */
  .outgoing-message {
    background: var(--accent);
    color: var(--text);
    border-radius: 12px 0 12px 12px;
    padding: 10px 14px;
    align-self: flex-end;
    padding-right: 20px;
    max-width: 75%;
  }
  /* ---------- CARD / CAROUSEL / IMAGE ---------- */
  .card-container,
  .carousel-item,
  .image-bubble {
    max-width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    margin-top: 4px;
  }

  /* ---------- FORM ---------- */
  .form-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    margin-top: 4px;
  }

  /* ---------- AUDIO / VIDEO ---------- */
  audio,
  video {
    width: 100%;
    border-radius: 8px;
  }

  /* ---------- LOCATION ---------- */
  iframe[src*="google.com/maps"] {
    width: 100%;
    height: 200px;
    border-radius: 8px;
    border: none;
    margin-top: 4px;
  }

  /* ---------- TYPING INDICATOR ---------- */
  .typing-indicator {
    background: var(--secondary);
    border-radius: 18px;
    padding: 10px 10px;
    display: inline-block;
    margin: 5px 0 5px 10px;
    max-width: 15%;
  }

  .typing-dots {
    display: flex;
    align-items: center;
    height: 17px;
  }

  .typing-dots span {
    background: var(--text);
    border-radius: 50%;
    display: inline-block;
    height: 7px;
    width: 7px;
    margin: 0 2px;
    opacity: 0.4;
  }

  .typing-dots span:nth-child(1) {
    animation: typingAnimation 1s infinite;
  }

  .typing-dots span:nth-child(2) {
    animation: typingAnimation 1s infinite 0.2s;
  }

  .typing-dots span:nth-child(3) {
    animation: typingAnimation 1s infinite 0.4s;
  }

  @keyframes typingAnimation {
    0% {
      opacity: 0.4;
      transform: translateY(0);
    }

    50% {
      opacity: 1;
      transform: translateY(-3px);
    }

    100% {
      opacity: 0.4;
      transform: translateY(0);
    }
  }

  /* Responsive Fixes */
  @media (max-width: 1024px) {
    #chat-pane {
      width: 100% !important;
      min-width: auto !important;
    }

    #dynamic-pane {
      display: none !important;
      /* hide secondary panel on small screens */
    }
  }

  @media (max-height: 700px) {

    .chat-header,
    .top-bar,
    .bottom-bar {
      height: auto !important;
      /* stop squashing */
      min-height: 40px;
    }

    #chat-pane {
      height: 100% !important;
    }
  }

  html,
  body {
    overflow: auto !important;
    /* allow scrolling if layout overflows */
  }

}