/* ============================================
   Argus Web - Global Styles
   Design: Clean light/dark with always-dark sidebar
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', 'Segoe UI', 'Roboto', sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* ============================================
   Sidebar — Always dark, regardless of theme
   ============================================ */
.sidebar-drawer {
    background: #0D1B2A !important;
    border-right: none !important;
}

.sidebar-drawer .mud-drawer-content {
    background: #0D1B2A !important;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 16px 8px;
}

.sidebar-logo-img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 8px;
}

.sidebar-brand {
    display: flex;
    flex-direction: column;
}

.sidebar-brand-name {
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.sidebar-brand-name::first-letter {
    color: #4DD9C0;
}

.sidebar-brand-sub {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.7rem;
    letter-spacing: 0.5px;
}

.sidebar-tenant {
    padding: 8px 16px 12px;
}

.tenant-chip {
    font-size: 0.65rem !important;
    height: 22px !important;
    letter-spacing: 1px;
    font-weight: 600;
}

.sidebar-nav {
    padding: 0 8px;
}

.sidebar-nav .mud-nav-link {
    color: rgba(255, 255, 255, 0.6) !important;
    border-radius: 8px;
    margin: 2px 0;
    font-size: 0.875rem;
    font-weight: 400;
    transition: all 0.2s ease;
}

.sidebar-nav .mud-nav-link:hover {
    background: rgba(77, 217, 192, 0.08) !important;
    color: rgba(255, 255, 255, 0.9) !important;
}

.sidebar-nav .mud-nav-link.active {
    background: rgba(77, 217, 192, 0.12) !important;
    color: white !important;
    font-weight: 500;
}

.sidebar-nav .mud-nav-link.active .mud-icon-root {
    color: #4DD9C0 !important;
}

.chat-ai-badge {
    font-size: 0.6rem !important;
    height: 18px !important;
    padding: 0 6px !important;
    font-weight: 700;
}

.sidebar-admin-label {
    padding: 16px 0 4px;
}

.sidebar-user {
    padding: 12px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-footer {
    display: flex;
    justify-content: space-between;
    padding: 8px 16px 12px;
}

/* ============================================
   Main Content
   ============================================ */
.main-content {
    padding: 24px 32px !important;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ============================================
   Login Page
   ============================================ */
.login-container {
    display: flex;
    min-height: 100vh;
}

.login-left {
    flex: 1;
    background: linear-gradient(135deg, #0D1B2A 0%, #1B3A4B 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 60px 80px;
    position: relative;
    overflow: hidden;
}

.login-left::before {
    content: '';
    position: absolute;
    top: -100px;
    left: -100px;
    width: 400px;
    height: 400px;
    border: 2px solid rgba(77, 217, 192, 0.08);
    border-radius: 50%;
}

.login-left::after {
    content: '';
    position: absolute;
    bottom: -50px;
    right: -50px;
    width: 300px;
    height: 300px;
    border: 2px solid rgba(77, 217, 192, 0.06);
    border-radius: 50%;
}

.login-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 48px;
}

.login-logo img {
    width: 56px;
    height: 56px;
    object-fit: contain;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    border-radius: 8px;
}

.login-logo-text {
    display: flex;
    flex-direction: column;
}

.login-logo-name {
    color: white;
    font-size: 1.3rem;
    font-weight: 600;
}

.login-logo-name span {
    color: #4DD9C0;
}

.login-logo-sub {
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.login-tagline {
    color: white;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 12px;
}

.login-tagline span {
    color: #4DD9C0;
}

.login-description {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 40px;
    max-width: 420px;
}

.login-features {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login-feature {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.login-feature-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(77, 217, 192, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.login-feature-icon svg {
    width: 12px;
    height: 12px;
    fill: #4DD9C0;
}

.login-feature-text strong {
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    display: block;
}

.login-feature-text span {
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.8rem;
}

.login-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 60px 64px;
    background: white;
}

.login-form-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1A2332;
    margin-bottom: 4px;
}

.login-form-subtitle {
    color: #5A6B7B;
    font-size: 0.9rem;
    margin-bottom: 32px;
}

.login-btn {
    background: linear-gradient(135deg, #4DD9C0 0%, #36BFA8 100%) !important;
    color: white !important;
    font-weight: 600 !important;
    letter-spacing: 0.5px;
    border-radius: 8px !important;
    height: 48px !important;
    font-size: 0.95rem !important;
    text-transform: none !important;
    box-shadow: 0 4px 14px rgba(77, 217, 192, 0.3) !important;
}

.login-btn:hover {
    box-shadow: 0 6px 20px rgba(77, 217, 192, 0.4) !important;
}

.login-footer {
    position: absolute;
    bottom: 24px;
    left: 80px;
    color: rgba(255, 255, 255, 0.25);
    font-size: 0.75rem;
}

/* ============================================
   Chat Page Layout
   ============================================ */
.chat-page-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 48px);
}

.chat-page-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 0 16px;
}

.chat-page-header img {
    width: 36px;
    height: 36px;
}

.chat-messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 0 20%;
}

.chat-input-container {
    padding: 16px 20% 8px;
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #4DD9C0, #36BFA8);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(77, 217, 192, 0.35);
}

.chat-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Chat message bubbles — user always teal */
.chat-message-user {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
}

.chat-message-user .chat-bubble {
    background: #4DD9C0;
    color: #0D1B2A;
    border-radius: 18px 18px 4px 18px;
    padding: 10px 16px;
    max-width: 70%;
    font-size: 0.9rem;
    font-weight: 500;
}

.chat-message-assistant {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 12px;
}

.chat-message-assistant .chat-bubble {
    border-radius: 18px 18px 18px 4px;
    padding: 12px 16px;
    max-width: 80%;
    font-size: 0.9rem;
    line-height: 1.6;
    white-space: pre-wrap;
}

.chat-bubble-md {
    white-space: normal !important;
}

/* ============================================
   Tool Execution Indicators
   ============================================ */
.chat-tool-indicators {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 0;
    max-width: 80%;
}

.tool-chip {
    animation: tool-pulse 2s ease-in-out infinite;
    font-size: 0.76rem !important;
    border-color: rgba(77, 217, 192, 0.4) !important;
}

@keyframes tool-pulse {
    0%, 100% { opacity: 0.65; }
    50% { opacity: 1; }
}

/* ============================================
   Scrollbar
   ============================================ */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(128, 128, 128, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(128, 128, 128, 0.35);
}

/* Table wrapper scrollbar — thinner, subtle */
.table-responsive-wrapper::-webkit-scrollbar {
    height: 4px;
}

.table-responsive-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.table-responsive-wrapper::-webkit-scrollbar-thumb {
    background: rgba(77, 217, 192, 0.3);
    border-radius: 2px;
}

.table-responsive-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(77, 217, 192, 0.5);
}

/* ============================================
   Animations (shared)
   ============================================ */
@keyframes thinking-spin {
    to { transform: rotate(360deg); }
}

@keyframes thinking-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes thinking-text-pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* ============================================
   Blazor error UI
   ============================================ */
#blazor-error-ui {
    display: none !important;
}

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "Ha ocurrido un error.";
}


/* ================================================================
   ================================================================
   LIGHT THEME — .theme-light (main content area)
   Clean white/light gray, like the login page right panel
   ================================================================
   ================================================================ */

/* --- Welcome Screen --- */
.theme-light .chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px;
}

.theme-light .chat-welcome-icon {
    width: 110px;
    height: 110px;
    margin-bottom: 24px;
    opacity: 0.85;
    object-fit: contain;
}

.theme-light .chat-welcome-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: #1A2332;
}

.theme-light .chat-welcome-subtitle {
    font-size: 0.9rem;
    color: #5A6B7B;
    margin-bottom: 36px;
    text-align: center;
}

.theme-light .chat-quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    max-width: 560px;
    width: 100%;
}

.theme-light .chat-quick-card {
    border: 1px solid #E2E8F0;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
}

.theme-light .chat-quick-card:hover {
    border-color: #4DD9C0;
    background: rgba(77, 217, 192, 0.04);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.theme-light .chat-quick-card-icon {
    margin-bottom: 8px;
    color: #5A6B7B;
}

.theme-light .chat-quick-card-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 2px;
    color: #1A2332;
}

.theme-light .chat-quick-card-desc {
    font-size: 0.8rem;
    color: #8896A6;
}

.theme-light .chat-disclaimer {
    font-size: 0.75rem;
    color: #A0AEC0;
    margin-top: 24px;
    text-align: center;
}

/* --- Chat Input --- */
.theme-light .chat-input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid #E2E8F0;
    border-radius: 28px;
    padding: 8px 8px 8px 24px;
    transition: border-color 0.2s;
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.theme-light .chat-input-wrapper:focus-within {
    border-color: #4DD9C0;
    box-shadow: 0 0 0 3px rgba(77, 217, 192, 0.12);
}

.theme-light .chat-input-wrapper input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.9rem;
    color: #1A2332;
}

.theme-light .chat-input-wrapper input::placeholder {
    color: #A0AEC0;
}

/* --- Assistant Bubble --- */
.theme-light .chat-message-assistant .chat-bubble {
    background: #F5F7FA;
    border: 1px solid #E8ECF1;
}

/* --- Thinking Indicator --- */
.theme-light .chat-thinking-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: 16px;
    background: rgba(77, 217, 192, 0.06);
    border: 1px solid rgba(77, 217, 192, 0.18);
    animation: thinking-fade-in 0.3s ease-out;
}

.theme-light .chat-thinking-spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(77, 217, 192, 0.25);
    border-top-color: #36BFA8;
    border-radius: 50%;
    animation: thinking-spin 0.8s linear infinite;
    flex-shrink: 0;
}

.theme-light .chat-thinking-text {
    color: #2D9B85;
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    animation: thinking-text-pulse 2.5s ease-in-out infinite;
}

/* --- Markdown — Light --- */
.theme-light .markdown-body {
    font-size: 0.9rem;
    line-height: 1.7;
    word-wrap: break-word;
    color: #334155;
}

.theme-light .markdown-body > *:first-child {
    margin-top: 0;
}

.theme-light .markdown-body > *:last-child {
    margin-bottom: 0;
}

.theme-light .markdown-body h1,
.theme-light .markdown-body h2,
.theme-light .markdown-body h3,
.theme-light .markdown-body h4 {
    margin: 16px 0 8px;
    font-weight: 600;
    line-height: 1.3;
    color: #0D8B73;
}

.theme-light .markdown-body h1 { font-size: 1.3rem; }
.theme-light .markdown-body h2 { font-size: 1.15rem; }
.theme-light .markdown-body h3 { font-size: 1.0rem; }
.theme-light .markdown-body h4 { font-size: 0.92rem; color: #475569; }

.theme-light .markdown-body h1:first-child,
.theme-light .markdown-body h2:first-child,
.theme-light .markdown-body h3:first-child {
    margin-top: 0;
}

.theme-light .markdown-body p {
    margin: 0 0 8px;
}

.theme-light .markdown-body p:last-child {
    margin-bottom: 0;
}

.theme-light .markdown-body strong {
    font-weight: 600;
    color: #1A2332;
}

.theme-light .markdown-body em {
    font-style: italic;
    opacity: 0.85;
}

/* Table Responsive Wrapper — Light */
.theme-light .markdown-body .table-responsive-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 12px 0;
    border-radius: 8px;
    border: 1px solid #E2E8F0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    position: relative;
}

/* Tables — Light */
.theme-light .markdown-body table {
    width: 100%;
    min-width: 320px;
    border-collapse: separate;
    border-spacing: 0;
    margin: 0;
    font-size: 0.82rem;
    border-radius: 0;
    overflow: visible;
    background: white;
    border: none;
    box-shadow: none;
}

.theme-light .markdown-body thead th {
    background: #F0FAF7;
    color: #0D8B73;
    font-weight: 600;
    text-align: left;
    padding: 10px 14px;
    border-bottom: 2px solid #D1FAE5;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.theme-light .markdown-body tbody td {
    padding: 8px 14px;
    border-bottom: 1px solid #F1F5F9;
    color: #334155;
    white-space: nowrap;
}

.theme-light .markdown-body tbody tr:hover {
    background: #F8FFFE;
}

.theme-light .markdown-body tbody tr:last-child td {
    border-bottom: none;
}

.theme-light .markdown-body td strong,
.theme-light .markdown-body th strong {
    color: #0D8B73;
}

/* Lists — Light */
.theme-light .markdown-body ul,
.theme-light .markdown-body ol {
    margin: 8px 0;
    padding-left: 22px;
}

.theme-light .markdown-body li {
    margin: 4px 0;
    line-height: 1.6;
}

.theme-light .markdown-body li::marker {
    color: #36BFA8;
}

.theme-light .markdown-body li > ul,
.theme-light .markdown-body li > ol {
    margin: 2px 0;
}

/* HR — Light */
.theme-light .markdown-body hr {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, #D1FAE5, transparent);
    margin: 16px 0;
}

/* Code — Light */
.theme-light .markdown-body code {
    background: #F0FAF7;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.82rem;
    color: #0D8B73;
    border: 1px solid #E2E8F0;
}

.theme-light .markdown-body pre {
    background: #F8FAFC;
    border-radius: 8px;
    padding: 14px 18px;
    overflow-x: auto;
    margin: 12px 0;
    border: 1px solid #E2E8F0;
}

.theme-light .markdown-body pre code {
    background: none;
    padding: 0;
    font-size: 0.82rem;
    color: #334155;
    border: none;
}

/* Blockquotes — Light */
.theme-light .markdown-body blockquote {
    border-left: 3px solid #36BFA8;
    margin: 12px 0;
    padding: 8px 16px;
    background: #F0FAF7;
    border-radius: 0 8px 8px 0;
}

.theme-light .markdown-body blockquote p {
    margin: 0;
    color: #475569;
}

/* Links — Light */
.theme-light .markdown-body a {
    color: #0D8B73;
    text-decoration: none;
}

.theme-light .markdown-body a:hover {
    text-decoration: underline;
    color: #36BFA8;
}

/* --- Logs Page — Light --- */
.theme-light .logs-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 48px);
}

.theme-light .logs-container {
    flex: 1;
    overflow-y: auto;
    background: #1A2332;
    border-radius: 8px;
    padding: 12px;
    font-family: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.78rem;
    line-height: 1.7;
}


/* ================================================================
   ================================================================
   DARK THEME — .theme-dark (main content area)
   Original dark design
   ================================================================
   ================================================================ */

/* --- Welcome Screen --- */
.theme-dark .chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px;
}

.theme-dark .chat-welcome-icon {
    width: 110px;
    height: 110px;
    margin-bottom: 24px;
    opacity: 0.9;
    object-fit: contain;
}

.theme-dark .chat-welcome-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: rgba(255, 255, 255, 0.9);
}

.theme-dark .chat-welcome-subtitle {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 36px;
    text-align: center;
}

.theme-dark .chat-quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    max-width: 560px;
    width: 100%;
}

.theme-dark .chat-quick-card {
    border: 1px solid rgba(128, 128, 128, 0.15);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
}

.theme-dark .chat-quick-card:hover {
    border-color: #4DD9C0;
    background: rgba(77, 217, 192, 0.04);
    transform: translateY(-1px);
}

.theme-dark .chat-quick-card-icon {
    margin-bottom: 8px;
    color: rgba(255, 255, 255, 0.5);
}

.theme-dark .chat-quick-card-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 2px;
    color: rgba(255, 255, 255, 0.9);
}

.theme-dark .chat-quick-card-desc {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.45);
}

.theme-dark .chat-disclaimer {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.35);
    margin-top: 24px;
    text-align: center;
}

/* --- Chat Input --- */
.theme-dark .chat-input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid rgba(128, 128, 128, 0.2);
    border-radius: 28px;
    padding: 8px 8px 8px 24px;
    transition: border-color 0.2s;
    background: rgba(255, 255, 255, 0.03);
}

.theme-dark .chat-input-wrapper:focus-within {
    border-color: #4DD9C0;
}

.theme-dark .chat-input-wrapper input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.9);
}

.theme-dark .chat-input-wrapper input::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

/* --- Assistant Bubble --- */
.theme-dark .chat-message-assistant .chat-bubble {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

/* --- Thinking Indicator --- */
.theme-dark .chat-thinking-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: 16px;
    background: rgba(77, 217, 192, 0.06);
    border: 1px solid rgba(77, 217, 192, 0.15);
    animation: thinking-fade-in 0.3s ease-out;
}

.theme-dark .chat-thinking-spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(77, 217, 192, 0.2);
    border-top-color: #4DD9C0;
    border-radius: 50%;
    animation: thinking-spin 0.8s linear infinite;
    flex-shrink: 0;
}

.theme-dark .chat-thinking-text {
    color: rgba(77, 217, 192, 0.85);
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    animation: thinking-text-pulse 2.5s ease-in-out infinite;
}

/* --- Markdown — Dark --- */
.theme-dark .markdown-body {
    font-size: 0.9rem;
    line-height: 1.7;
    word-wrap: break-word;
    color: rgba(255, 255, 255, 0.9);
}

.theme-dark .markdown-body > *:first-child {
    margin-top: 0;
}

.theme-dark .markdown-body > *:last-child {
    margin-bottom: 0;
}

.theme-dark .markdown-body h1,
.theme-dark .markdown-body h2,
.theme-dark .markdown-body h3,
.theme-dark .markdown-body h4 {
    margin: 16px 0 8px;
    font-weight: 600;
    line-height: 1.3;
    color: #4DD9C0;
}

.theme-dark .markdown-body h1 { font-size: 1.3rem; }
.theme-dark .markdown-body h2 { font-size: 1.15rem; }
.theme-dark .markdown-body h3 { font-size: 1.0rem; }
.theme-dark .markdown-body h4 { font-size: 0.92rem; color: rgba(255, 255, 255, 0.85); }

.theme-dark .markdown-body h1:first-child,
.theme-dark .markdown-body h2:first-child,
.theme-dark .markdown-body h3:first-child {
    margin-top: 0;
}

.theme-dark .markdown-body p {
    margin: 0 0 8px;
}

.theme-dark .markdown-body p:last-child {
    margin-bottom: 0;
}

.theme-dark .markdown-body strong {
    font-weight: 600;
    color: rgba(255, 255, 255, 0.97);
}

.theme-dark .markdown-body em {
    font-style: italic;
    opacity: 0.9;
}

/* Table Responsive Wrapper — Dark */
.theme-dark .markdown-body .table-responsive-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 12px 0;
    border-radius: 8px;
    border: 1px solid rgba(77, 217, 192, 0.15);
    position: relative;
}

/* Tables — Dark */
.theme-dark .markdown-body table {
    width: 100%;
    min-width: 320px;
    border-collapse: separate;
    border-spacing: 0;
    margin: 0;
    font-size: 0.82rem;
    border-radius: 0;
    overflow: visible;
    background: rgba(0, 0, 0, 0.2);
    border: none;
}

.theme-dark .markdown-body thead th {
    background: rgba(77, 217, 192, 0.12);
    color: #4DD9C0;
    font-weight: 600;
    text-align: left;
    padding: 10px 14px;
    border-bottom: 2px solid rgba(77, 217, 192, 0.25);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.theme-dark .markdown-body tbody td {
    padding: 8px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.85);
    white-space: nowrap;
}

.theme-dark .markdown-body tbody tr:hover {
    background: rgba(77, 217, 192, 0.06);
}

.theme-dark .markdown-body tbody tr:last-child td {
    border-bottom: none;
}

.theme-dark .markdown-body td strong,
.theme-dark .markdown-body th strong {
    color: #4DD9C0;
}

.theme-dark .markdown-body td:has(strong) {
    font-weight: 500;
}

/* Lists — Dark */
.theme-dark .markdown-body ul,
.theme-dark .markdown-body ol {
    margin: 8px 0;
    padding-left: 22px;
}

.theme-dark .markdown-body li {
    margin: 4px 0;
    line-height: 1.6;
}

.theme-dark .markdown-body li::marker {
    color: #4DD9C0;
}

.theme-dark .markdown-body li > ul,
.theme-dark .markdown-body li > ol {
    margin: 2px 0;
}

/* HR — Dark */
.theme-dark .markdown-body hr {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(77, 217, 192, 0.3), transparent);
    margin: 16px 0;
}

/* Code — Dark */
.theme-dark .markdown-body code {
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.82rem;
    color: #4DD9C0;
}

.theme-dark .markdown-body pre {
    background: rgba(0, 0, 0, 0.35);
    border-radius: 8px;
    padding: 14px 18px;
    overflow-x: auto;
    margin: 12px 0;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.theme-dark .markdown-body pre code {
    background: none;
    padding: 0;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.85);
}

/* Blockquotes — Dark */
.theme-dark .markdown-body blockquote {
    border-left: 3px solid #4DD9C0;
    margin: 12px 0;
    padding: 8px 16px;
    background: rgba(77, 217, 192, 0.05);
    border-radius: 0 8px 8px 0;
}

.theme-dark .markdown-body blockquote p {
    margin: 0;
    opacity: 0.9;
}

/* Links — Dark */
.theme-dark .markdown-body a {
    color: #4DD9C0;
    text-decoration: none;
}

.theme-dark .markdown-body a:hover {
    text-decoration: underline;
}

/* --- Logs Page — Dark --- */
.theme-dark .logs-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 48px);
}

.theme-dark .logs-container {
    flex: 1;
    overflow-y: auto;
    background: #0D1B2A;
    border-radius: 8px;
    padding: 12px;
    font-family: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.78rem;
    line-height: 1.7;
}

/* ============================================
   Logs — Shared styles (no theme prefix)
   ============================================ */
.logs-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 48px);
}

.logs-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 16px;
    flex-wrap: wrap;
}

.logs-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logs-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logs-count-chip {
    font-size: 0.7rem !important;
    height: 22px !important;
}

.logs-container {
    flex: 1;
    overflow-y: auto;
    background: #1A2332;
    border-radius: 8px;
    padding: 12px;
    font-family: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.78rem;
    line-height: 1.7;
}

.logs-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: rgba(255, 255, 255, 0.4);
}

.log-entry {
    display: flex;
    gap: 8px;
    padding: 2px 4px;
    border-radius: 2px;
    white-space: nowrap;
}

.log-entry:hover {
    background: rgba(255, 255, 255, 0.04);
}

.log-time {
    color: rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}

.log-level {
    flex-shrink: 0;
    font-weight: 600;
    min-width: 30px;
    text-align: center;
}

.log-level-error { color: #FF6B6B; }
.log-level-warning { color: #FFD93D; }
.log-level-info { color: #4DD9C0; }
.log-level-debug { color: rgba(255, 255, 255, 0.35); }

.log-source {
    color: #6C9BCF;
    flex-shrink: 0;
}

.log-message {
    color: rgba(255, 255, 255, 0.85);
    overflow: hidden;
    text-overflow: ellipsis;
}

.log-details {
    color: rgba(255, 255, 255, 0.35);
    overflow: hidden;
    text-overflow: ellipsis;
    font-style: italic;
    cursor: help;
}

.log-entry.log-error {
    background: rgba(255, 107, 107, 0.06);
}

.log-entry.log-warning {
    background: rgba(255, 217, 61, 0.04);
}

.logs-footer {
    padding: 8px 0 0;
    text-align: right;
}


/* ================================================================
   ================================================================
   RESPONSIVE — Mobile App Bar + Breakpoints
   ================================================================
   ================================================================ */

/* Mobile App Bar — hidden on large screens, shown on small */
.mobile-appbar {
    background: #0D1B2A !important;
    color: white !important;
}

/* On large screens (>=1280px): hide the mobile appbar, sidebar is always visible */
@media (min-width: 1280px) {
    .mobile-appbar {
        display: none !important;
    }
}

/* ============================================
   TABLET — max-width: 1279px
   Sidebar becomes overlay, chat gets less padding
   ============================================ */
@media (max-width: 1279px) {
    .main-content {
        padding: 16px 20px !important;
    }

    .chat-messages-area {
        padding: 0 10%;
    }

    .chat-input-container {
        padding: 12px 10% 8px;
    }

    .chat-message-user .chat-bubble {
        max-width: 80%;
    }

    .chat-message-assistant .chat-bubble {
        max-width: 90%;
    }

    .chat-tool-indicators {
        max-width: 90%;
    }
}

/* ============================================
   MOBILE — max-width: 768px
   Everything stacks, full-width, minimal padding
   ============================================ */
@media (max-width: 768px) {
    /* --- Main Content --- */
    .main-content {
        padding: 12px 12px !important;
        padding-top: 60px !important; /* space for mobile appbar */
    }

    /* --- Chat Layout --- */
    .chat-page-container {
        height: calc(100vh - 60px);
    }

    .chat-page-header {
        padding: 0 0 8px;
    }

    .chat-page-header img {
        width: 28px;
        height: 28px;
    }

    .chat-messages-area {
        padding: 0 4px;
    }

    .chat-input-container {
        padding: 8px 4px 6px;
    }

    /* Bubbles full width on mobile */
    .chat-message-user .chat-bubble {
        max-width: 90%;
        font-size: 0.85rem;
        padding: 8px 14px;
    }

    .chat-message-assistant .chat-bubble {
        max-width: 95%;
        padding: 10px 12px;
    }

    .chat-tool-indicators {
        max-width: 95%;
    }

    /* --- Welcome Screen --- */
    .theme-light .chat-welcome,
    .theme-dark .chat-welcome {
        padding: 20px 12px;
    }

    .theme-light .chat-welcome-icon,
    .theme-dark .chat-welcome-icon {
        width: 70px;
        height: 70px;
        margin-bottom: 16px;
    }

    .theme-light .chat-welcome-title,
    .theme-dark .chat-welcome-title {
        font-size: 1.2rem;
    }

    .theme-light .chat-welcome-subtitle,
    .theme-dark .chat-welcome-subtitle {
        font-size: 0.82rem;
        margin-bottom: 24px;
    }

    /* Quick cards — single column on mobile */
    .theme-light .chat-quick-actions,
    .theme-dark .chat-quick-actions {
        grid-template-columns: 1fr;
        max-width: 100%;
        gap: 8px;
    }

    .theme-light .chat-quick-card,
    .theme-dark .chat-quick-card {
        padding: 14px 16px;
    }

    .theme-light .chat-disclaimer,
    .theme-dark .chat-disclaimer {
        margin-top: 16px;
    }

    /* --- Input wrapper compact --- */
    .theme-light .chat-input-wrapper,
    .theme-dark .chat-input-wrapper {
        padding: 6px 6px 6px 16px;
        border-radius: 24px;
    }

    .theme-light .chat-input-wrapper input,
    .theme-dark .chat-input-wrapper input {
        font-size: 0.85rem;
    }

    .chat-send-btn {
        width: 36px;
        height: 36px;
    }

    /* --- Tables: assistant bubble expands for tables --- */
    .chat-message-assistant .chat-bubble:has(.table-responsive-wrapper) {
        max-width: 100%;
    }

    /* --- Table responsive wrapper — proper scroll on mobile --- */
    .theme-light .markdown-body .table-responsive-wrapper,
    .theme-dark .markdown-body .table-responsive-wrapper {
        margin: 8px -4px;
        border-radius: 6px;
        /* Subtle scroll hint shadow on right */
        background:
            linear-gradient(to right, transparent 90%, rgba(0,0,0,0.06)) right;
        background-size: 100% 100%;
        background-repeat: no-repeat;
    }

    .theme-dark .markdown-body .table-responsive-wrapper {
        background:
            linear-gradient(to right, transparent 90%, rgba(0,0,0,0.2)) right;
        background-size: 100% 100%;
        background-repeat: no-repeat;
    }

    /* --- Table cells: compact on mobile --- */
    .theme-light .markdown-body thead th,
    .theme-dark .markdown-body thead th {
        padding: 8px 10px;
        font-size: 0.72rem;
        letter-spacing: 0.3px;
    }

    .theme-light .markdown-body tbody td,
    .theme-dark .markdown-body tbody td {
        padding: 6px 10px;
        font-size: 0.78rem;
    }

    /* First column (concept/label) can wrap, others stay nowrap */
    .theme-light .markdown-body tbody td:first-child,
    .theme-dark .markdown-body tbody td:first-child {
        white-space: normal;
        min-width: 100px;
        max-width: 160px;
        word-break: break-word;
    }

    /* Numeric/short columns stay on one line */
    .theme-light .markdown-body tbody td:not(:first-child),
    .theme-dark .markdown-body tbody td:not(:first-child) {
        white-space: nowrap;
        text-align: right;
    }

    .theme-light .markdown-body thead th:not(:first-child),
    .theme-dark .markdown-body thead th:not(:first-child) {
        text-align: right;
    }

    /* --- Markdown text compact --- */
    .theme-light .markdown-body,
    .theme-dark .markdown-body {
        font-size: 0.85rem;
        line-height: 1.6;
    }

    .theme-light .markdown-body h1,
    .theme-dark .markdown-body h1 {
        font-size: 1.1rem;
    }

    .theme-light .markdown-body h2,
    .theme-dark .markdown-body h2 {
        font-size: 1.0rem;
    }

    .theme-light .markdown-body h3,
    .theme-dark .markdown-body h3 {
        font-size: 0.92rem;
    }

    /* --- Thinking indicator compact --- */
    .theme-light .chat-thinking-indicator,
    .theme-dark .chat-thinking-indicator {
        padding: 10px 14px;
        border-radius: 12px;
    }

    .theme-light .chat-thinking-text,
    .theme-dark .chat-thinking-text {
        font-size: 0.8rem;
    }

    /* --- Login Page — stack vertically --- */
    .login-container {
        flex-direction: column;
    }

    .login-left {
        padding: 32px 24px;
        min-height: auto;
    }

    .login-left::before,
    .login-left::after {
        display: none;
    }

    .login-logo {
        margin-bottom: 24px;
    }

    .login-logo img {
        width: 40px;
        height: 40px;
    }

    .login-logo-name {
        font-size: 1.1rem;
    }

    .login-tagline {
        font-size: 1.4rem;
        margin-bottom: 8px;
    }

    .login-description {
        font-size: 0.85rem;
        margin-bottom: 20px;
    }

    .login-features {
        gap: 10px;
    }

    .login-feature-text strong {
        font-size: 0.82rem;
    }

    .login-feature-text span {
        font-size: 0.72rem;
    }

    .login-right {
        padding: 32px 24px;
    }

    .login-form-title {
        font-size: 1.3rem;
    }

    .login-form-subtitle {
        font-size: 0.82rem;
        margin-bottom: 20px;
    }

    .login-btn {
        height: 44px !important;
        font-size: 0.9rem !important;
    }

    .login-footer {
        position: static;
        text-align: center;
        padding: 16px 0;
        left: auto;
    }

    /* --- Logs Page --- */
    .log-entry {
        white-space: normal;
        flex-wrap: wrap;
        gap: 4px;
    }

    .log-time {
        font-size: 0.7rem;
    }

    .log-source {
        font-size: 0.7rem;
    }

    .log-message {
        width: 100%;
        font-size: 0.72rem;
    }

    .logs-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    /* --- Sidebar adjustments for overlay --- */
    .sidebar-logo-img {
        width: 40px;
        height: 40px;
    }

    .sidebar-brand-name {
        font-size: 1rem;
    }
}

/* ============================================
   SMALL MOBILE — max-width: 480px
   Extra compact for very small screens
   ============================================ */
@media (max-width: 480px) {
    .main-content {
        padding: 8px 8px !important;
        padding-top: 56px !important;
    }

    .chat-messages-area {
        padding: 0 2px;
    }

    .chat-input-container {
        padding: 6px 2px 4px;
    }

    .chat-message-user .chat-bubble {
        max-width: 95%;
        font-size: 0.82rem;
    }

    .chat-message-assistant .chat-bubble {
        max-width: 98%;
    }

    .theme-light .chat-welcome-icon,
    .theme-dark .chat-welcome-icon {
        width: 56px;
        height: 56px;
    }

    .theme-light .chat-welcome-title,
    .theme-dark .chat-welcome-title {
        font-size: 1.05rem;
    }

    /* --- Tables: ultra-compact on small mobile --- */
    .theme-light .markdown-body thead th,
    .theme-dark .markdown-body thead th {
        padding: 6px 8px;
        font-size: 0.68rem;
        letter-spacing: 0.2px;
    }

    .theme-light .markdown-body tbody td,
    .theme-dark .markdown-body tbody td {
        padding: 5px 8px;
        font-size: 0.74rem;
    }

    .theme-light .markdown-body tbody td:first-child,
    .theme-dark .markdown-body tbody td:first-child {
        min-width: 80px;
        max-width: 130px;
    }

    .theme-light .markdown-body .table-responsive-wrapper,
    .theme-dark .markdown-body .table-responsive-wrapper {
        margin: 6px -2px;
    }

    /* Login even more compact */
    .login-left {
        padding: 24px 16px;
    }

    .login-right {
        padding: 24px 16px;
    }

    .login-tagline {
        font-size: 1.2rem;
    }

    .login-description {
        display: none; /* hide description on very small screens */
    }

    .login-features {
        display: none; /* hide features list on very small screens */
    }
}
