:root {
  --primary: #1b2f51;
  --secondary: #448ec1;
  --white: #ffffff;
  --gray-100: #f8f9fa;
  --gray-200: #e9ecef;
  --gray-300: #dee2e6;
  --gray-400: #ced4da;
  --gray-500: #adb5bd;
  --gray-600: #6c757d;
  --gray-700: #495057;
  --gray-800: #343a40;
  --red: #dc3545;
  --yellow: #ffc107;
  --green: #28a745;
  --sidebar-width: 240px;
  --sidebar-collapsed: 60px;
  --header-height: 0px;
  --transition: 0.3s ease;

  /* Modern transitions and shadows - TailwindCSS v4 inspired */
  --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1),
    0 4px 6px -4px rgb(0 0 0 / 0.1);
}

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

html,
body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  font-size: 14px;
}

.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  transition: width var(--transition-smooth),
    box-shadow var(--transition-smooth);
  position: relative;
  z-index: 100;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar__header {
  padding: 16px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 70px;
  background: linear-gradient(
    135deg,
    rgba(27, 47, 81, 0.02) 0%,
    transparent 100%
  );
}

.sidebar__brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: var(--primary);
  overflow: hidden;
}

.sidebar__logo {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.sidebar__brand-text {
  margin-left: 12px;
  display: flex;
  flex-direction: column;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition), width var(--transition);
}

.sidebar.collapsed .sidebar__brand-text {
  opacity: 0;
  width: 0;
  margin-left: 0;
}

.sidebar__brand-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--primary);
  letter-spacing: -0.02em;
}

/* Modern marquee subtitle wrapper */
.sidebar__brand-subtitle-wrapper {
  overflow: hidden;
  width: 100%;
  position: relative;
  height: 16px;
  mask-image: linear-gradient(
    to right,
    transparent,
    black 10%,
    black 90%,
    transparent
  );
  -webkit-mask-image: linear-gradient(
    to right,
    transparent,
    black 10%,
    black 90%,
    transparent
  );
}

.sidebar__brand-subtitle-track {
  display: flex;
  width: max-content;
  animation: marquee-scroll 10s linear infinite;
}

.sidebar__brand-subtitle {
  font-size: 11px;
  color: var(--secondary);
  white-space: nowrap;
  padding-right: 4em;
  font-weight: 500;
  flex-shrink: 0;
}

@keyframes marquee-scroll {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-33.333%);
  }
}

.sidebar__toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-600);
  transition: all var(--transition-smooth);
  flex-shrink: 0;
}

.sidebar__toggle:hover {
  background: var(--gray-100);
  color: var(--secondary);
  transform: scale(1.05);
}

.sidebar__toggle svg {
  width: 20px;
  height: 20px;
  transition: transform var(--transition-smooth);
}

.sidebar.collapsed .sidebar__toggle svg {
  transform: rotate(180deg);
}

.sidebar__nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar__link {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  margin-bottom: 4px;
  text-decoration: none;
  color: var(--gray-700);
  border-radius: 8px;
  transition: all var(--transition-smooth);
  white-space: nowrap;
  overflow: hidden;
  position: relative;
}

/* Modern left border indicator */
.sidebar__link::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 0;
  background: var(--secondary);
  transition: height var(--transition-smooth);
  border-radius: 0 2px 2px 0;
}

.sidebar__link:hover {
  background: linear-gradient(
    90deg,
    rgba(68, 142, 193, 0.08) 0%,
    rgba(68, 142, 193, 0.03) 100%
  );
  color: var(--secondary);
  transform: translateX(2px);
}

.sidebar__link:hover::before {
  height: 70%;
}

.sidebar__link--active {
  background: linear-gradient(
    90deg,
    rgba(68, 142, 193, 0.12) 0%,
    rgba(68, 142, 193, 0.05) 100%
  );
  color: var(--secondary);
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

.sidebar__link--active::before {
  height: 70%;
}

/* Special styling for Panel (home) button */
.sidebar__link[data-icon-type="home"] {
  font-weight: 600;
}

.sidebar__link[data-icon-type="home"]:hover .sidebar__link-icon {
  transform: scale(1.1);
}

.sidebar__link[data-icon-type="home"].sidebar__link--active {
  background: linear-gradient(
    90deg,
    rgba(68, 142, 193, 0.15) 0%,
    rgba(68, 142, 193, 0.06) 100%
  );
  box-shadow: var(--shadow-md);
}

.sidebar__link-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast);
}

.sidebar__link-icon svg,
.sidebar__link-icon img {
  width: 20px;
  height: 20px;
}

.sidebar__link-text {
  margin-left: 12px;
  transition: opacity var(--transition-smooth);
}

.sidebar.collapsed .sidebar__link-text {
  opacity: 0;
  width: 0;
  margin-left: 0;
}

.sidebar__separator {
  height: 1px;
  background: var(--gray-200);
  margin: 12px 8px;
}

.sidebar__footer {
  padding: 12px;
  border-top: 1px solid var(--gray-200);
}

.sidebar__footer-link {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  text-decoration: none;
  color: var(--gray-600);
  border-radius: 8px;
  transition: all var(--transition-smooth);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar__footer-link:hover {
  background: var(--gray-100);
}

.sidebar.collapsed .sidebar__footer-text {
  opacity: 0;
  width: 0;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--gray-100);
}

.main__content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.iframe-container {
  width: 100%;
  height: 100%;
  border: none;
}

.iframe-container iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 40px;
  color: var(--gray-600);
  animation: fadeIn 0.6s ease-out;
}

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

.welcome-screen__logo {
  width: 80px;
  height: 80px;
  margin-bottom: 24px;
  opacity: 0.6;
  transition: all var(--transition-smooth);
}

.welcome-screen__logo:hover {
  opacity: 0.8;
  transform: scale(1.05);
}

.welcome-screen__title {
  font-size: 24px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 8px;
}

.welcome-screen__subtitle {
  font-size: 14px;
  color: var(--gray-500);
}

/* =========================================================
   MOBILE HEADER
   ========================================================= */

.mobile-header {
  display: none;
}

.mobile-header__toggle {
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: var(--gray-700);
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-header__toggle i {
  font-size: 24px;
}

.mobile-header__title {
  margin-left: 12px;
  font-weight: 600;
  color: var(--primary);
}

/* =========================================================
   TOAST NOTIFICATIONS
   ========================================================= */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--primary);
  color: var(--white);
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 2000;
  transform: translateY(100px);
  opacity: 0;
  transition: all var(--transition);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast--success {
  background: var(--green);
}

.toast--error {
  background: var(--red);
}

/* =========================================================
   SERVICES WITH CHATBOT (Calendar, Sheets)
   ========================================================= */

body.google-sheets-page,
body.google-calendar-page {
  margin: 0;
  padding: 0;
  height: 100vh;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--gray-100);
}

body.google-sheets-page *,
body.google-calendar-page * {
  box-sizing: border-box;
}

body.google-sheets-page .main-container,
body.google-calendar-page .main-container {
  display: flex;
  width: 100%;
  height: 100%;
}

body.google-sheets-page .iframe-wrapper,
body.google-calendar-page .iframe-wrapper {
  flex: 1;
  height: 100%;
  min-width: 0;
  background: #fdfefe;
}

body.google-sheets-page .iframe-wrapper iframe,
body.google-calendar-page .iframe-wrapper iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Chatbot Panel */
body.google-sheets-page .chatbot-panel,
body.google-calendar-page .chatbot-panel {
  width: 360px;
  height: 100%;
  background: var(--white);
  border-left: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

body.google-sheets-page .chatbot-header,
body.google-calendar-page .chatbot-header {
  padding: 16px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: var(--white);
  display: flex;
  align-items: center;
  gap: 10px;
}

.chatbot-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

body.google-sheets-page .chatbot-header span,
body.google-calendar-page .chatbot-header span {
  font-weight: 600;
  font-size: 14px;
}

body.google-sheets-page .chatbot-messages,
body.google-calendar-page .chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f5f7fb;
}

body.google-sheets-page .chatbot-messages::-webkit-scrollbar,
body.google-calendar-page .chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

body.google-sheets-page .chatbot-messages::-webkit-scrollbar-thumb,
body.google-calendar-page .chatbot-messages::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 3px;
}

/* Chat Messages */
body.google-sheets-page .chat-message,
body.google-calendar-page .chat-message {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  word-wrap: break-word;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
  animation: messageIn 0.3s ease-out;
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

body.google-sheets-page .chat-message.bot,
body.google-calendar-page .chat-message.bot {
  background: #ffffff;
  color: var(--primary);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

body.google-sheets-page .chat-message.user,
body.google-calendar-page .chat-message.user {
  background: linear-gradient(135deg, var(--secondary) 0%, #5ca4d4 100%);
  color: var(--white);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

body.google-sheets-page .chat-message.error,
body.google-calendar-page .chat-message.error {
  background: #fee2e2;
  color: #dc2626;
  align-self: flex-start;
}

/* Markdown content in messages */
body.google-sheets-page .chat-message pre,
body.google-calendar-page .chat-message pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 10px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 8px 0;
  font-size: 12px;
}

body.google-sheets-page .chat-message code,
body.google-calendar-page .chat-message code {
  background: #e2e8f0;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

body.google-sheets-page .chat-message a,
body.google-calendar-page .chat-message a {
  color: #2563eb;
  text-decoration: underline;
}

/* WhatsApp-style Audio Player */
.audio-player {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: linear-gradient(135deg, var(--secondary) 0%, #5ca4d4 100%);
  border-radius: 18px;
  min-width: 160px;
  max-width: 220px;
  margin-top: 0.4rem;
}

.audio-player .play-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  color: white;
}

.audio-player .play-btn svg {
  width: 12px;
  height: 12px;
  fill: white;
}

.audio-player .progress-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.audio-player .progress-bar {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
}

.audio-player .progress-fill {
  height: 100%;
  background: white;
  border-radius: 2px;
  width: 0%;
  transition: width 0.1s;
}

.audio-player .progress-dot {
  position: absolute;
  width: 10px;
  height: 10px;
  background: white;
  border-radius: 50%;
  top: -3px;
  left: 0%;
  transform: translateX(-50%);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.audio-player .audio-time {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.9);
  font-variant-numeric: tabular-nums;
}

.chat-message audio {
  display: none;
}

/* Chatbot Input Area */
body.google-sheets-page .chatbot-input-container,
body.google-calendar-page .chatbot-input-container {
  padding: 12px;
  border-top: 1px solid var(--gray-200);
  background: var(--white);
}

body.google-sheets-page .chatbot-input-wrapper,
body.google-calendar-page .chatbot-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 0.4rem;
  background: var(--gray-100);
  border: 1.5px solid var(--gray-300);
  border-radius: 24px;
  padding: 0.3rem;
  transition: all 0.2s;
}

body.google-sheets-page .chatbot-input-wrapper:focus-within,
body.google-calendar-page .chatbot-input-wrapper:focus-within {
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(68, 142, 193, 0.2);
}

body.google-sheets-page .chatbot-input-wrapper.recording,
body.google-calendar-page .chatbot-input-wrapper.recording {
  border-color: var(--red);
  background: rgba(220, 53, 69, 0.1);
}

body.google-sheets-page .chatbot-input,
body.google-calendar-page .chatbot-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  padding: 8px 4px;
  resize: none;
  min-height: 36px;
  max-height: 100px;
  outline: none;
  color: var(--gray-800);
  line-height: 1.35;
}

body.google-sheets-page .chatbot-input::placeholder,
body.google-calendar-page .chatbot-input::placeholder {
  color: var(--gray-500);
}

/* Action Buttons */
.chatbot-action-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--gray-600);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.chatbot-action-btn:hover {
  color: var(--secondary);
  background: rgba(68, 142, 193, 0.1);
}

.chatbot-action-btn svg {
  width: 20px;
  height: 20px;
}

body.google-sheets-page .chatbot-send-btn,
body.google-calendar-page .chatbot-send-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: linear-gradient(135deg, var(--secondary) 0%, #5ca4d4 100%);
  color: var(--white);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  flex-shrink: 0;
  box-shadow: var(--shadow-md);
}

body.google-sheets-page .chatbot-send-btn:hover,
body.google-calendar-page .chatbot-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(68, 142, 193, 0.3);
}

body.google-sheets-page .chatbot-send-btn:disabled,
body.google-calendar-page .chatbot-send-btn:disabled {
  background: var(--gray-300);
  color: var(--gray-500);
  cursor: not-allowed;
  box-shadow: none;
}

body.google-sheets-page .chatbot-send-btn.recording,
body.google-calendar-page .chatbot-send-btn.recording {
  background: var(--red);
  animation: sendBtnPulse 1.2s infinite;
}

@keyframes sendBtnPulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.4);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 0 8px rgba(220, 53, 69, 0);
  }
}

/* Recording UI */
.recording-ui {
  display: none;
  flex: 1;
  align-items: center;
  gap: 0.6rem;
  padding: 0 0.4rem;
}

.chatbot-input-wrapper.recording .recording-ui {
  display: flex;
}

.chatbot-input-wrapper.recording .chatbot-input {
  display: none;
}

.recording-indicator {
  width: 10px;
  height: 10px;
  background: var(--red);
  border-radius: 50%;
  animation: recordingPulse 1s infinite;
  flex-shrink: 0;
}

@keyframes recordingPulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(0.85);
  }
}

.recording-time {
  font-size: 0.8rem;
  color: var(--red);
  font-variant-numeric: tabular-nums;
  min-width: 40px;
  flex-shrink: 0;
}

.cancel-recording {
  color: var(--gray-600);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0.4rem;
  flex-shrink: 0;
}

.cancel-recording:hover {
  color: var(--gray-800);
}

/* Typing Indicator */
body.google-sheets-page .typing-indicator,
body.google-calendar-page .typing-indicator {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  background: #e9edf7;
  border-radius: 12px;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

body.google-sheets-page .typing-indicator span,
body.google-calendar-page .typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--gray-600);
  border-radius: 50%;
  animation: typing-bounce 1.4s infinite;
}

body.google-sheets-page .typing-indicator span:nth-child(2),
body.google-calendar-page .typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

body.google-sheets-page .typing-indicator span:nth-child(3),
body.google-calendar-page .typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-6px);
  }
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    z-index: 200;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar.collapsed {
    width: var(--sidebar-width);
  }

  .mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 150;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition);
  }

  .mobile-overlay.active {
    opacity: 1;
    visibility: visible;
  }

  .mobile-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
  }

  /* Hide chatbot panel on mobile for Calendar/Sheets */
  body.google-sheets-page .chatbot-panel,
  body.google-calendar-page .chatbot-panel {
    display: none;
  }
}
