/* ========================================================
   TamilAI Workspace Core Engine Mobile Responsive Profiles
   ======================================================== */

@media screen and (max-width: 768px) {
  * {
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box; /* Ensures padding calculations don't stretch layouts */
  }

  /* 1. FORCE CORE LAYOUTS TO RENDER WITHIN TRUE DYNAMIC VIEWPORT HEIGHTS */
  body {
    overflow: hidden;
    height: 100dvh !important; /* Overrides classic broken vh */
    position: fixed;
    width: 100%;
    top: 0;
    left: 0;
    background-size: cover !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
  }
  .workspace,
  .main-chat,
  .chat-box {
    background: transparent !important;
  }

  .app-container {
    height: 100dvh !important;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: transparent !important;
  }

  /* 2. RE-CALIBRATED MAIN WORKSPACE SPACE CONTAINER */
  .workspace {
    height: calc(
      100dvh - 38px - 14px
    ) !important; /* Screen minus topbar and footer */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    background: transparent !important;
  }

  /* TINY TOPBAR HEADER - Ultra compact single-row design */
  .topbar {
    height: 38px;
    padding: 2px 8px;
    flex-direction: row;
    gap: 4px;
    align-items: center;
    justify-content: space-between;
    background: #060c1a !important;
    z-index: 1000;
  }

  .top-left {
    display: flex;
    align-items: center;
    gap: 4px;
    width: auto;
  }

  .logo-box {
    padding: 2px 6px;
    border-radius: 6px;
  }

  .logo-box h2 {
    font-size: 11px;
  }

  .new-chat {
    width: auto;
    height: auto;
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 6px;
  }

  /* TINY CONVERSATIONS TRACK - Horizontal scrollbar path */
  .top-history {
    display: flex !important;
    position: absolute;
    top: 38px;
    left: 0;
    margin: 0;
    width: 100%;
    height: 28px; /* Slightly widened to prevent scroll squeezing text */
    overflow-x: auto;
    overflow-y: visible !important;
    background: rgba(6, 12, 26, 0.95) !important;
    border-bottom: 1px solid rgba(0, 229, 255, 0.08);
    -webkit-overflow-scrolling: touch;
    z-index: 999;
  }

  /* CRITICAL MOBILE MENU DROP RE-CALIBRATION */
  .chat-history-list .dropdown-menu,
  .chat-history-list .menu-options,
  .chat-menu-dropdown,
  .global-chat-menu {
    position: fixed !important;
    background: #091724 !important;
    border: 1px solid #00e5ff !important;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    padding: 4px;
    width: auto;
    min-width: 110px;
    z-index: 100000 !important;
  }

  .chat-history-list {
    gap: 4px;
    padding: 2px 6px;
    align-items: center;
    height: 100%;
  }

  .chat-history-list li {
    min-width: 90px;
    max-width: 110px;
    padding: 2px 6px;
    border-radius: 6px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .chat-title {
    font-size: 9px;
  }

  .chat-menu-btn {
    font-size: 9px;
    padding: 0 2px;
  }

  /* HIDE SIDEBAR & TOP-RIGHT EXTRAS FOR DYNAMIC SPACE SAVING */
  .sidebar {
    display: none !important;
  }

  .top-right {
    position: static;
    display: flex;
    align-items: center;
    gap: 4px;
  }

  .theme-btn,
  .user-profile {
    width: 24px;
    height: 24px;
    font-size: 11px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
  }

  /* HUGE MAIN WORKSPACE SCREEN SETUP */
  .main-chat {
    width: 100%;
    height: 100%;
    padding: 4px;
    margin-top: 28px; /* Offset exactly for the top horizontal conversation track row */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: transparent !important; /* Strips gray layers */
  }

  /* FORCED DEEP BLUE AND ANIMATED NEON BORDER GLOW CONTAINER */
  .conversation-workspace {
    height: 100%;
    padding: 10px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;

    /* True Blue Workspace Profile Styles */
    background: rgba(5, 15, 35, 0.25) !important;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(0, 229, 255, 0.25) !important;
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.1) !important;

    /* Neon Glow Breathing Animation */
    animation: workspaceNeonPulse 3s infinite ease-in-out !important;
  }

  .conversation-top {
    margin-bottom: 8px;
    padding-bottom: 6px;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(0, 229, 255, 0.1) !important;
  }
  .conversation-workspace::before {
    display: none !important;
  }

  .conversation-ai-info h2,
  .conversation-user-info h3 {
    font-size: 8px;
    color: #00e5ff !important; /* Cyber neon cyan titles */
  }

  /* 3. FIXED CHAT BOX VIEWPORT BUFFER HEIGHT CALCULATIONS */
  .chat-box {
    padding: 6px;
    gap: 12px;
    overflow-y: auto !important;
    background: transparent !important; /* Clear out gray masks inside chat list tracking */

    /* Forces chat window to fit cleanly above the absolute input layout bar */
    height: calc(100dvh - 155px) !important;
    margin-bottom: 65px !important; /* Increased to push the messages safely above the input container */
    padding-bottom: 30px !important; /* Extra breathing space inside the scroll container */
  }

  /* COMPACT MESSAGE BALLOONS */
  .ai-message,
  .user-message {
    font-size: 12px;
    padding: 8px 12px;
    max-width: 85%;
    border-radius: 12px !important;
  }

  .ai-message {
    background: rgba(0, 229, 255, 0.08) !important;
    border: 1px solid rgba(0, 229, 255, 0.2) !important;
    color: #ffffff !important;
  }

  .user-message {
    background: rgba(0, 110, 255, 0.15) !important;
    border: 1px solid rgba(0, 110, 255, 0.3) !important;
    color: #ffffff !important;
  }

  .message-date {
    font-size: 7px;
    margin-top: 4px;
    opacity: 0.6;
  }

  /* 4. PINNED MESSAGE INPUT AREA BAR - Pinned down perfectly at screen boundary views */
  .input-area {
    position: fixed !important;
    bottom: 14px !important; /* Sits perfectly flush right atop our footer container */
    left: 8px !important;
    right: 8px !important;
    width: calc(100% - 16px) !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    padding: 6px 10px !important;
    gap: 6px !important;
    background: #060d1a !important; /* Solid ambient mask so text background scales underneath beautifully */
    border: 1px solid rgba(0, 229, 255, 0.25) !important;
    border-radius: 12px !important;
    z-index: 9999 !important;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.1) !important;
  }

  .input-area textarea {
    height: 36px !important;
    min-height: 36px !important;
    max-height: 80px !important;
    font-size: 14px !important; /* Fixes iOS Safari focus layout auto-zooming bugs */
    padding: 8px 0 !important;
    line-height: 18px !important;
    flex: 1 !important;
    background: transparent !important;
    color: #ffffff !important;
  }

  .input-actions {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 4px !important;
  }

  .action-btn {
    width: 32px !important;
    height: 32px !important;
    font-size: 13px !important;
    border-radius: 8px !important;
    background: rgba(0, 229, 255, 0.05) !important;
    border: 1px solid rgba(0, 229, 255, 0.15) !important;
    color: #00e5ff !important;
  }

  .send-btn {
    height: 32px !important;
    font-size: 12px !important;
    padding: 0 12px !important;
    border-radius: 8px !important;
    background: #00e5ff !important;
    color: #040811 !important;
    font-weight: bold;
  }

  /* FOOTER STATUS STRIP TRACKER */
  .footer {
    height: 14px;
    font-size: 7px;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 10000;
    background: #040811 !important;
  }

  /* AMBIENT RUNTIME ENGINE LIMITATIONS */
  .cursor-glow,
  .click-ripple {
    display: none !important;
  }
}

/* ========================================================
   ANIMATION TIMELINE ENGINES
   ======================================================== */
@keyframes workspaceNeonPulse {
  0% {
    border-color: rgba(0, 229, 255, 0.2) !important;
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.05) !important;
  }
  50% {
    border-color: rgba(0, 229, 255, 0.45) !important;
    box-shadow: 0 0 22px rgba(0, 229, 255, 0.2) !important;
  }
  100% {
    border-color: rgba(0, 229, 255, 0.2) !important;
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.05) !important;
  }
}

/* ========================================================
   GLOBAL LIGHT MODE THEME COMPATIBILITY EXTENSIONS
   ======================================================== */
body.light-mode .top-history {
  background: rgba(255, 255, 255, 0.8) !important;
  border-bottom-color: rgba(0, 0, 0, 0.08) !important;
}

body.light-mode .conversation-workspace {
  background: #ffffff !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
  animation: none !important;
  box-shadow: none !important;
}

body.light-mode .input-area {
  background: #f4f6f9 !important;
  border-color: rgba(0, 0, 0, 0.15) !important;
  box-shadow: none !important;
}

body.light-mode .input-area textarea {
  color: #111b2c !important;
}

body.light-mode .action-btn {
  background: rgba(0, 0, 0, 0.03) !important;
  border-color: rgba(0, 0, 0, 0.08) !important;
  color: #111b2c !important;
}

body.light-mode .chat-box {
  background: rgba(255, 255, 255, 0.6) !important;
}
/* 1. Clear full screening on the outer dark wrapper */
#customFeaturesOverlay {
  display: none; /* Controlled by JavaScript flex toggles */
  position: fixed !important;
  top: 0;
  left: 0;
  width: 100vw !important;
  height: 100dvh !important;
  background: rgba(
    4,
    8,
    17,
    0.75
  ) !important; /* Soft darkened backdrop click mask */
  backdrop-filter: blur(4px) !important;
  z-index: 100001 !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 20px !important;
}

/* 2. RE-SIZE THE INNER CONTENT MODAL BOX BOX PERFECTLY */
#customFeaturesOverlay > div,
.custom-features-content {
  width: 90% !important; /* Prevents edge stretching */
  max-width: 340px !important; /* Locks a clean compact profile size */
  max-height: 70dvh !important; /* Prevents overflow clipping off-screen */
  background: #09111e !important; /* Solid sleek deep space theme color */
  border: 1px solid rgba(0, 229, 255, 0.3) !important; /* Cyber neon blue frame */
  border-radius: 16px !important;
  padding: 16px !important;
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.6),
    0 0 15px rgba(0, 229, 255, 0.15) !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 12px !important;
  overflow-y: auto !important; /* Safe scroll trait for internal buttons */
}

/* 3. Compact sizing tweaks for internal action items inside modal box */
.custom-features-content h3 {
  font-size: 14px !important;
  color: #00e5ff !important;
  margin-bottom: 4px;
  text-align: center;
}

.custom-features-content button {
  padding: 10px !important;
  font-size: 12px !important;
  border-radius: 8px !important;
}
/* ========================================================
   TAMILAI WORKSPACE - DESKTOP ONLY NEON ANIMATED SCROLLBAR
   ======================================================== */
@media screen and (min-width: 769px) {
  /* 1. Track setup */
  ::-webkit-scrollbar {
    width: 8px !important;
  }

  /* 2. Track background */
  ::-webkit-scrollbar-track {
    background: #040811 !important;
  }

  /* 3. The Neon Handle */
  ::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #00e5ff, #0066ff) !important;
    border-radius: 10px !important;
    border: 1px solid rgba(0, 229, 255, 0.2) !important;
    /* Adding a subtle glow */
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.5) !important;
  }

  /* 4. Animation for the Neon effect */
  ::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #39ff14, #00e5ff) !important;
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.8) !important;
    transition: all 0.3s ease !important;
  }
}
/* ========================================================
   TAMILAI WORKSPACE - MOBILE FONT SCALE CONTROLLER
   ======================================================== */
/* ========================================================
   TAMILAI WORKSPACE - FORCED MOBILE FONT OVERRIDE
   ======================================================== */
@media screen and (max-width: 768px) {
  /* Use triple-class/ID specificity to beat the themes.css file */
  .chat-box .message-date,
  div.chat-box .message-date,
  #chatBox .message-date {
    font-size: 8px !important;
    font-weight: 400 !important;
    letter-spacing: 0px !important;
    margin-top: 2px !important;
    display: block !important;
    white-space: nowrap !important; /* Prevents awkward line breaks */
    text-shadow: none !important; /* Removes heavy desktop shadows */
    color: #00e5ff;
  }
}
#particles-js {
  opacity: 0.25 !important;
}
@media (max-width: 768px) {
  .login-container,
  .register-container {
    width: 90%;
    padding: 25px;
  }

  .logo-title {
    font-size: 2.5rem;
  }

  .login-container input,
  .register-container input {
    height: 48px;
    margin-bottom: 12px;
  }

  .login-btn,
  .register-btn {
    height: 50px;
  }

  .subtitle {
    font-size: 14px;
  }
}
/* ===================================
   SETTINGS MOBILE OPTIMIZATION
=================================== */

@media (max-width: 768px) {
  .settings-modal {
    width: 95%;
    height: 85vh;
    max-height: 85vh;
    overflow-y: auto;
    padding: 15px;
    border-radius: 20px;
  }

  .settings-content {
    overflow-y: auto;
    max-height: 70vh;
  }

  .settings-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .settings-tab {
    font-size: 12px;
    padding: 8px 10px;
  }

  select {
    width: 100%;
    font-size: 14px;
  }

  .settings-footer {
    position: sticky;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    padding-top: 10px;
  }

  .save-btn,
  .cancel-btn {
    width: 100%;
    margin-bottom: 10px;
  }
  .settings-dashboard {
    padding: 8px 10px !important;
    font-size: 12px !important;
  }
  .profile-dropdown {
    top: 45px !important;
    right: 0 !important;
  }
}
