/* Grok.ai inspired dark theme design */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Base colors */
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    --bg-tertiary: #141414;
    --bg-sidebar: #0f0f0f;
    --bg-input: #1a1a1a;
    --bg-surface: rgba(255, 255, 255, 0.02);
    --bg-overlay: rgba(0, 0, 0, 0.4);

    /* Text colors */
    --text-primary: #ffffff;
    --text-secondary: #b8b8b8;
    --text-muted: #6b6b6b;
    --text-accent: #00d9ff;

    /* Accent colors */
    --accent-primary: #00d9ff;
    --accent-secondary: rgba(0, 217, 255, 0.1);
    --accent-tertiary: rgba(0, 217, 255, 0.05);

    /* Border colors */
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --border-active: #00d9ff;

    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.6);

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Border radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 24px;

    /* Transitions */
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: row;
    line-height: 1.6;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Auth page (login / landing) */
.auth-page {
    min-height: 100vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, var(--accent-tertiary), transparent),
        radial-gradient(ellipse 60% 40% at 100% 50%, var(--accent-tertiary), transparent),
        radial-gradient(ellipse 60% 40% at 0% 50%, var(--accent-tertiary), transparent),
        linear-gradient(180deg, #050508 0%, #0a0a0f 50%, #000000 100%);
}

/* Auth logo styles */
.auth-logo-container {
    width: 80px;
    height: 80px;
    margin: 0 auto var(--space-xl);
    border-radius: var(--radius-xl);
    background: linear-gradient(135deg, var(--accent-secondary) 0%, var(--accent-tertiary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--accent-primary);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    position: relative;
    overflow: hidden;
    transition: all var(--transition-normal);
}

.auth-logo-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform var(--transition-slow);
}

.auth-container:hover .auth-logo-container::before {
    transform: translateX(100%);
}

.auth-logo-container svg,
.auth-logo-container img {
    width: 48px;
    height: 48px;
    opacity: 0.9;
    transition: opacity var(--transition-fast);
    object-fit: contain;
}

.auth-container:hover .auth-logo-container svg,
.auth-container:hover .auth-logo-container img {
    opacity: 1;
}

.auth-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(0, 217, 255, 0.04) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(0, 217, 255, 0.03) 0%, transparent 50%);
    pointer-events: none;
}

.auth-page::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 64px 64px;
    pointer-events: none;
    opacity: 0.5;
}

/* Auth Container */
.auth-container {
    max-width: 420px;
    width: 100%;
    margin: 0 var(--space-lg);
    position: relative;
    z-index: 1;
    background: var(--bg-overlay);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    padding: var(--space-2xl) var(--space-xl);
    border-radius: var(--radius-2xl);
    border: 1px solid var(--border-color);
    box-shadow:
        0 16px 64px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.03) inset,
        0 1px 0 rgba(255, 255, 255, 0.05) inset;
    position: relative;
    overflow: hidden;
    transition: all var(--transition-normal);
}

.auth-container:hover {
    transform: translateY(-2px);
    box-shadow:
        0 24px 80px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset,
        0 1px 0 rgba(255, 255, 255, 0.07) inset;
}

.auth-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-primary), transparent);
    opacity: 0.6;
}

/* Auth typography */
.auth-container h1 {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin: 0 0 var(--space-sm) 0;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-container .subtitle {
    font-size: 16px;
    font-weight: 400;
    color: var(--text-muted);
    margin: 0;
    letter-spacing: 0.2px;
}

/* Auth header and logo */
.auth-header {
    text-align: center;
    margin-bottom: var(--space-2xl);
}

.auth-container h1 {
    text-align: center;
    margin-bottom: 6px;
    color: var(--text-primary);
    font-size: 28px;
    font-weight: 500;
    letter-spacing: -0.8px;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
}

.auth-container h1.auth-logo-title {
    font-size: inherit;
    font-weight: inherit;
    font-family: inherit;
    letter-spacing: inherit;
}
.auth-header .logo-text {
    display: inline-flex;
    align-items: baseline;
    gap: 0;
}
.auth-header .logo-brand {
    font-family: 'Satisfy', cursive;
    font-size: 34px;
    font-weight: 400;
    color: var(--text-primary);
}
.auth-header .logo-ai {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 1.45em;
    color: var(--accent-primary);
    letter-spacing: 0.1em;
    text-shadow: 0 0 24px rgba(0, 217, 255, 0.5);
}

.auth-container .subtitle {
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 40px;
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0.2px;
    text-transform: uppercase;
}

.auth-container input {
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    margin-bottom: var(--space-md);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-size: 15px;
    color: var(--text-primary);
    transition: all var(--transition-fast);
    font-weight: 400;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.auth-container input:focus {
    outline: none;
    border-color: var(--border-hover);
    background: var(--bg-surface);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.auth-container input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.auth-container button {
    width: 100%;
    padding: var(--space-md);
    background: linear-gradient(135deg, var(--text-primary) 0%, rgba(255, 255, 255, 0.95) 100%);
    color: var(--bg-primary);
    border: none;
    border-radius: var(--radius-lg);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    letter-spacing: 0.2px;
    margin-top: var(--space-sm);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.auth-container button::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(0, 217, 255, 0.1) 100%);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.auth-container button:hover:not(:disabled) {
    background: var(--text-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.auth-container button:hover:not(:disabled)::before {
    opacity: 1;
}

.auth-container button:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.auth-container button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.error {
    color: #ff6b6b;
    margin-bottom: 16px;
    text-align: center;
    font-size: 13px;
    padding: 12px;
    background: rgba(255, 107, 107, 0.1);
    border-radius: 10px;
    border: 1px solid rgba(255, 107, 107, 0.2);
    font-weight: 400;
}

/* 2FA Setup Section */
#setup2FASection input:focus {
    outline: none;
    border-color: var(--border-hover);
    background: var(--bg-surface);
}

#setup2FASection button:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

/* Header */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: var(--space-lg) var(--space-xl);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    background: rgba(10, 10, 10, 0.8);
}

/* Em mobile, garantir que o header não sobrepõe o botão toggle */
@media (max-width: 768px) {
    .header {
        z-index: 99;
    }
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    font-size: 22px;
    font-weight: 700;
    color: var(--accent-primary);
    letter-spacing: -0.4px;
    transition: all var(--transition-fast);
}

/* JoaquAIm brand text in top bar – script for name, tech-style emphasis on AI */
.logo-text {
    display: inline-flex;
    align-items: baseline;
    gap: 0;
}
.logo-brand {
    font-family: 'Satisfy', cursive;
    font-weight: 400;
    font-size: 26px;
    letter-spacing: 0.02em;
    line-height: 1.2;
    color: var(--text-primary);
}
.logo-ai {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 1.4em;
    color: var(--accent-primary);
    letter-spacing: 0.1em;
    padding: 0 2px;
    text-shadow: 0 0 20px rgba(0, 217, 255, 0.5);
    vertical-align: baseline;
}
.logo:hover .logo-brand {
    color: var(--text-primary);
}
.logo:hover .logo-ai {
    color: var(--accent-primary);
    text-shadow: 0 0 24px rgba(0, 217, 255, 0.8);
}

.logo:hover {
    transform: translateY(-1px);
    color: var(--text-primary);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    margin: calc(var(--space-sm) * -1) calc(var(--space-md) * -1);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Model selector wrapper: Grok highlight when a Grok model is selected */
.model-select-wrap {
    position: relative;
    border-radius: 10px;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.model-select-wrap--grok {
    box-shadow: 0 0 0 1px rgba(0, 217, 255, 0.2);
    border-radius: 10px;
}
.model-select-wrap--grok .model-select {
    border-color: rgba(0, 217, 255, 0.35);
    background: linear-gradient(135deg, rgba(0, 217, 255, 0.04) 0%, var(--bg-input) 100%);
}

.model-select {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    height: 38px;
    padding: 0 36px 0 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 180px;
    max-width: 260px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2 4L6 8L10 4' stroke='%238b8b8b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    margin-left: 0;
}

.model-select:hover {
    border-color: var(--border-hover);
    background-color: var(--bg-tertiary);
}

.model-select:focus {
    outline: none;
    border-color: var(--border-hover);
}

/* Grok (xAI) optgroup highlight in dropdown */
.model-select optgroup.supplier-xai,
.model-select optgroup[data-supplier="xai"] {
    font-weight: 700;
    color: var(--accent-primary);
    background: rgba(0, 217, 255, 0.08);
}

.custom-model-input {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    height: 36px;
    padding: 0 12px;
    font-size: 13px;
    color: var(--text-primary);
    width: 160px;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.custom-model-input::placeholder {
    color: var(--text-muted);
}

.custom-model-input:focus {
    outline: none;
    border-color: var(--border-hover);
}

/* Unified header icon buttons */
.header-btn {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--text-secondary);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.header-btn:hover {
    background: var(--bg-surface);
    border-color: var(--border-hover);
    color: var(--text-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.header-btn:active {
    transform: translateY(0) scale(0.98);
}

.sidebar-menu-btn {
    margin-right: 4px;
}

#restartBtn:hover {
    transform: rotate(90deg);
}

#restartBtn:active {
    transform: rotate(90deg) scale(0.96);
}

.header-btn.refreshing,
#restartBtn.restarting {
    animation: spin 0.8s linear infinite;
    pointer-events: none;
    color: var(--text-primary);
}

/* Cursor usage widget (canto superior direito) */
.cursor-usage-widget {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 12px;
    margin-left: 2px;
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    white-space: nowrap;
}

.cursor-usage-widget:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.cursor-usage-widget .cursor-usage-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    color: inherit;
}

.cursor-usage-widget .cursor-usage-icon svg {
    flex-shrink: 0;
}

.cursor-usage-widget .cursor-usage-label {
    letter-spacing: 0.02em;
}

@media (max-width: 768px) {
    .cursor-usage-widget .cursor-usage-label {
        display: none;
    }
    .cursor-usage-widget {
        padding: 0 8px;
    }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.logo-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.logo-avatar svg {
    width: 24px;
    height: 24px;
}

/* Sidebar */
.sidebar {
    width: 300px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
    transition: all var(--transition-normal);
    z-index: 100;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.mobile-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.mobile-sidebar-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.sidebar.mobile-hidden {
    transform: translateX(-100%);
}

/* Desktop: sidebar colapsável para o lado */
@media (min-width: 769px) {
    .sidebar.sidebar-collapsed {
        transform: translateX(-100%);
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        z-index: 100;
    }
}

.sidebar-header {
    position: relative;
    padding: var(--space-lg) var(--space-md);
    border-bottom: 1px solid var(--border-color);
    overflow: visible;
    background: var(--bg-surface);
}

/* Menu name tooltip on hover for left bar top buttons */
.sidebar-btn-tooltip {
    position: relative;
}

.sidebar-btn-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translate(-50%, 0);
    margin-bottom: 6px;
    padding: 5px 10px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
    z-index: 1002;
    box-shadow: var(--shadow-md);
}

.sidebar-btn-tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

.new-chat-btn {
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    background: linear-gradient(135deg, var(--accent-secondary) 0%, var(--accent-tertiary) 100%);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.new-chat-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(0, 217, 255, 0.1) 100%);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.new-chat-btn:hover {
    background: linear-gradient(135deg, var(--accent-primary) 0%, rgba(0, 168, 204, 0.2) 100%);
    border-color: var(--border-active);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.new-chat-btn:hover::before {
    opacity: 1;
}

.new-chat-btn:active {
    transform: translateY(0);
}

.sidebar-search {
    margin-top: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    color: var(--text-primary);
    width: 100%;
    transition: all var(--transition-fast);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.sidebar-search:focus {
    border-color: var(--border-hover);
    background: var(--bg-surface);
}

.sidebar-search::placeholder {
    color: var(--text-muted);
}

.sidebar-buttons {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.settings-btn {
    flex: 1;
    height: 36px;
    padding: 0;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.settings-btn:hover {
    background: var(--bg-surface);
    border-color: var(--border-hover);
    color: var(--text-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.settings-btn:active {
    transform: translateY(0);
}

/* Settings Modal */
.settings-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn var(--transition-slow) ease-out;
}

.settings-modal.active {
    display: flex;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
        -webkit-backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }
}

/* Job Modal */
#jobModal {
    display: none;
}

#jobModal.active {
    display: flex;
}

.job-item {
    transition: all 0.2s ease;
}

.job-item:hover {
    border-color: var(--border-hover) !important;
    background: var(--bg-tertiary) !important;
}

.job-action-btn {
    transition: all 0.2s ease;
}

.job-action-btn:hover {
    background: var(--bg-tertiary) !important;
    border-color: var(--border-hover) !important;
    transform: scale(1.05);
}

.schedule-options {
    margin-top: 8px;
}

.settings-content {
    background: var(--bg-overlay);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-2xl);
    padding: var(--space-2xl);
    max-width: 520px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: modalSlideIn var(--transition-normal) ease-out;
}

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

.settings-content h2 {
    margin: 0 0 var(--space-lg) 0;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.4px;
}

.settings-group {
    margin-bottom: var(--space-lg);
}

.settings-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
    letter-spacing: 0.1px;
}

.settings-group small {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: var(--space-xs);
    line-height: 1.4;
}

.settings-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.settings-group input,
.settings-group textarea,
.settings-group select {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    color: var(--text-primary);
    font-family: inherit;
}

.settings-group input:focus,
.settings-group textarea:focus,
.settings-group select:focus {
    outline: none;
    border-color: var(--border-hover);
}

.settings-group textarea {
    min-height: 80px;
    resize: vertical;
}

.settings-group select {
    cursor: pointer;
}

.settings-actions {
    display: flex;
    gap: var(--space-md);
    margin-top: var(--space-2xl);
    justify-content: flex-end;
}

.settings-actions button {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-secondary) 0%, var(--accent-primary) 100%);
    color: var(--bg-primary);
    border: 1px solid var(--accent-primary);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.btn-primary::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(0, 217, 255, 0.1) 100%);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--accent-primary) 0%, rgba(0, 168, 204, 0.8) 100%);
    border-color: var(--accent-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-primary:hover::before {
    opacity: 1;
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.btn-secondary:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--border-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:active {
    transform: translateY(0);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
}

.history-section {
    margin-bottom: var(--space-xl);
}

.history-section-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: var(--space-sm);
    padding: 0 var(--space-sm);
    border-left: 3px solid var(--accent-primary);
    padding-left: calc(var(--space-sm) - 3px);
}

.history-section-favorites .history-section-title {
    color: var(--accent-primary, #00d9ff);
}

/* Ações rápidas: lista com ícone + título */
.auto-prompts-list {
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.auto-prompts-list .auto-prompts-empty {
    grid-column: 1 / -1;
}

.auto-prompt-item.auto-prompt-icon-btn {
    width: 100%;
    min-height: 36px;
    padding: 6px 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-secondary);
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    text-align: left;
}

.auto-prompt-item.auto-prompt-icon-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.auto-prompt-item-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auto-prompt-item.auto-prompt-icon-btn svg,
.auto-prompt-item.auto-prompt-icon-btn i,
.auto-prompt-item-icon i {
    font-size: 14px;
}

.auto-prompt-item-label {
    flex: 1;
    min-width: 0;
    font-size: 12px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Grid de ícones no modal (6 por linha no desktop) */
.auto-prompt-icon-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    min-height: 120px;
    max-height: 200px;
    overflow-y: auto;
    padding: 8px 0;
}

.auto-prompt-icon-option {
    width: 100%;
    aspect-ratio: 1;
    min-height: 32px;
    min-width: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    font-size: 18px;
    -webkit-tap-highlight-color: transparent;
}

.auto-prompt-icon-option:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-hover, var(--border-color));
}

.auto-prompt-icon-option.selected {
    background: rgba(0, 217, 255, 0.15);
    color: var(--accent-primary, #00d9ff);
    border-color: var(--accent-primary, #00d9ff);
}

.settings-group-label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.auto-prompts-manage-btn {
    width: 100%;
    padding: 6px 10px;
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.auto-prompts-manage-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.show-more-btn:hover {
    background: rgba(255,255,255,0.1) !important;
    color: rgba(255,255,255,0.8) !important;
    border-color: rgba(255,255,255,0.2) !important;
}

.history-item {
    padding: 10px 12px;
    margin-bottom: 4px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 14px;
    position: relative;
}

.history-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.history-item:hover .history-item-actions {
    opacity: 1;
}

.history-item.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-left: 2px solid var(--accent-primary);
}

.history-item-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.6;
}

.history-item-title-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.history-item-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-item-unread-badge {
    flex-shrink: 0;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--accent-primary, #00d9ff);
    color: var(--bg-primary, #0f0f0f);
    font-size: 11px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.history-item-actions {
    display: flex;
    gap: 0;
    opacity: 0;
    transition: opacity 0.2s ease;
    flex-shrink: 0;
    margin-left: 4px;
}

.history-item:hover .history-item-actions {
    opacity: 1;
}

.history-item-favorite,
.history-item-rename,
.history-item-delete {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    color: var(--text-muted);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    width: 18px;
    height: 18px;
    opacity: 0.5;
}

.history-item-favorite svg {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    fill: none;
}

.history-item-favorite:hover,
.history-item-favorite.history-item-favorite-active {
    color: var(--accent-primary, #00d9ff);
    opacity: 1;
}

.history-item-favorite.history-item-favorite-active svg {
    fill: var(--accent-primary, #00d9ff);
    stroke: var(--accent-primary, #00d9ff);
}

.history-item-rename svg,
.history-item-delete svg {
    width: 12px;
    height: 12px;
    stroke: currentColor;
}

.history-item-rename:hover {
    background: var(--bg-input);
    color: var(--text-secondary);
    opacity: 1;
}

.history-item-delete:hover {
    background: rgba(255, 59, 48, 0.1);
    color: var(--text-muted);
    opacity: 1;
}

.history-item.dragging {
    opacity: 0.5;
}

.history-item.drag-over {
    border-top: 2px solid var(--accent-primary);
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* Container */
.container {
    flex: 1;
    max-width: 1320px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    transition: justify-content 0.35s ease, align-items 0.35s ease, transform 0.35s ease;
}

/* Connection retry banner (shown on network error, hidden when reconnected) */
.connection-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    margin-bottom: 12px;
    border-radius: 10px;
    background: rgba(234, 179, 8, 0.12);
    border: 1px solid rgba(234, 179, 8, 0.3);
    color: rgba(255, 255, 255, 0.95);
    font-size: 14px;
    flex-shrink: 0;
}

.connection-banner-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(234, 179, 8, 0.4);
    border-top-color: rgba(234, 179, 8, 0.9);
    border-radius: 50%;
    animation: connection-banner-spin 0.8s linear infinite;
}

@keyframes connection-banner-spin {
    to { transform: rotate(360deg); }
}

.connection-banner-text {
    flex: 1;
}

/* Chat empty state background: stars/space effect (visible only when prompt is centered) */
.chat-empty-bg {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0;
    transition: opacity 0.4s ease;
    overflow: hidden;
}

.main-content.chat-empty .chat-empty-bg {
    opacity: 1;
}

/* Subtle gradient overlay so empty state feels like space (helps on mobile where fewer stars visible) */
.chat-empty-bg::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 50% at 50% 30%, rgba(0, 217, 255, 0.06), transparent 50%),
        radial-gradient(ellipse 60% 40% at 80% 70%, rgba(0, 168, 204, 0.04), transparent 45%),
        radial-gradient(ellipse 60% 40% at 20% 70%, rgba(0, 168, 204, 0.04), transparent 45%);
    pointer-events: none;
}

.chat-empty-bg .star {
    position: absolute;
    width: 2px;
    height: 2px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.7);
    animation: star-twinkle 4s ease-in-out infinite;
}

.chat-empty-bg .star.star-cyan {
    background: rgba(0, 217, 255, 0.5);
    animation-duration: 5s;
    animation-delay: 0.5s;
}

@media (prefers-reduced-motion: reduce) {
    .chat-empty-bg .star {
        animation: none;
        opacity: 0.5;
    }
}

@keyframes star-twinkle {
    0%, 100% { opacity: 0.25; transform: scale(1); }
    50% { opacity: 0.9; transform: scale(1.2); }
}

/* Chat empty state: input centered; container transparent so .chat-empty-bg stars show through */
.main-content.chat-empty .container {
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: 1;
    background: transparent;
    transform: translateY(-6vh);
}

.main-content.chat-empty #messages {
    flex: 0 0 auto;
    margin-bottom: 0;
    padding: 0;
    overflow: visible;
    max-height: none;
    position: relative;
    z-index: 1;
}

.main-content.chat-empty .input-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 960px;
    margin-top: 16px;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), margin 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 0;
    margin-bottom: 24px;
    scroll-behavior: smooth;
}

#messages::-webkit-scrollbar {
    width: 8px;
}

#messages::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

#messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

#messages::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}

/* Messages */
.message {
    display: flex;
    margin-bottom: var(--space-xl);
    animation: messageSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    gap: var(--space-md);
}

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

.message.user {
    justify-content: flex-end;
}

.message.assistant {
    justify-content: flex-start;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    overflow: hidden;
}

.message-avatar svg {
    width: 100%;
    height: 100%;
    display: block;
}

.message.user .message-avatar {
    order: 2;
    background: var(--bg-tertiary);
}

.message.assistant .message-avatar {
    background: transparent;
    border: none;
}

/* Message body: conteúdo + datetime por baixo (user e assistant) */
.message .message-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    max-width: 75%;
}

.message.assistant .message-body {
    flex: 1;
    gap: 8px;
}

.message.user .message-body {
    align-items: flex-end;
}

.message.assistant .message-body .message-content {
    max-width: 100%;
}

.message-content {
    max-width: 95%;
    padding: 16px 20px;
    border-radius: 16px;
    word-wrap: break-word;
    line-height: 1.6;
    font-size: 15px;
}

/* User messages: comfortable reading width and spacing for long instructions */
.message.user .message-content {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-right-radius: 4px;
    max-width: min(95%, 80em);
    min-width: 4.5em; /* evita bolha tão estreita que "oi" quebre em duas linhas */
    line-height: 1.65;
    padding: 18px 22px;
}

.message.assistant .message-content {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Token count only (cost must not appear after LLM is selected) */
.message-cost {
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-muted);
}

/* Data/hora sob cada mensagem — minimal e pequeno */
.message-datetime {
    display: block;
    margin-top: 2px;
    font-size: 10px;
    color: var(--text-muted);
    opacity: 0.75;
}

.message-content p {
    margin-bottom: 10px;
    line-height: 1.6;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message.user .message-content p {
    margin-bottom: 12px;
    line-height: 1.65;
}

.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
    margin: 16px 0 8px 0;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text-primary);
}

.message-content h1 {
    font-size: 1.5em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.message-content h2 {
    font-size: 1.3em;
    margin-top: 20px;
}

.message-content h3 {
    font-size: 1.1em;
    margin-top: 16px;
}

.message-content ul,
.message-content ol {
    margin: 12px 0;
    padding-left: 24px;
    line-height: 1.6;
}

.message.user .message-content ul,
.message.user .message-content ol {
    margin: 14px 0;
    padding-left: 26px;
}

.message-content li {
    margin: 6px 0;
}

.message.user .message-content li {
    margin: 8px 0;
}

.message-content code {
    background: var(--bg-input);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 0.9em;
    color: #00d9ff;
}

.message-content pre {
    background: var(--bg-input);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
    border: 1px solid var(--border-color);
}

.message-content pre code {
    background: transparent;
    padding: 0;
    color: var(--text-primary);
    font-size: 0.85em;
    line-height: 1.5;
}

.message-content strong {
    font-weight: 600;
    color: var(--text-primary);
}

.message-content em {
    font-style: italic;
    color: var(--text-secondary);
}

.message-content a {
    color: #00d9ff;
    text-decoration: underline;
    transition: color 0.2s ease;
}

.message-content a:hover {
    color: #00a8cc;
}

.message-content img {
    max-width: 100%;
    border-radius: 8px;
    margin: 12px 0;
    display: block;
    box-shadow: var(--shadow-md);
}

.message-content hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 16px 0;
}

/* Input Container */
.input-container {
    display: flex;
    gap: var(--space-sm);
    background: var(--bg-secondary);
    padding: var(--space-md);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    align-items: flex-end;
    flex-wrap: wrap;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all var(--transition-fast);
}

.input-container:focus-within {
    border-color: var(--border-hover);
}

.input-action-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
    border: 1px solid transparent;
}

.input-action-btn:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.input-action-btn:active {
    transform: translateY(0);
}

.input-action-btn.active {
    background: var(--bg-tertiary);
    color: #00d9ff;
}

.input-action-btn.recording {
    animation: pulse 1.5s ease-in-out infinite;
    color: #ff3b30;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.selected-photos {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    width: 100%;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.selected-photo {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.selected-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.selected-photo-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    padding: 0;
}

#userInput {
    flex: 1;
    min-height: 48px;
    max-height: 240px;
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-size: 15px;
    color: var(--text-primary);
    outline: none;
    transition: all var(--transition-fast);
    font-family: inherit;
    resize: none;
    overflow-y: auto;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    line-height: 1.5;
}

#userInput:focus {
    border-color: var(--border-hover);
    background: var(--bg-surface);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

#userInput::placeholder {
    color: var(--text-muted);
}

#sendButton {
    padding: var(--space-md) var(--space-xl);
    background: linear-gradient(135deg, var(--accent-secondary) 0%, var(--accent-primary) 100%);
    color: var(--bg-primary);
    border: 1px solid var(--accent-primary);
    border-radius: var(--radius-lg);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

#sendButton::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(0, 217, 255, 0.1) 100%);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

#sendButton:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--accent-primary) 0%, rgba(0, 168, 204, 0.8) 100%);
    border-color: var(--accent-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

#sendButton:hover:not(:disabled)::before {
    opacity: 1;
}

#sendButton:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

#sendButton:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Loading */
.loading {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-radius: 50%;
    border-top-color: var(--bg-primary);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Pulse animation for collapsed sidebar toggle */
@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 30px rgba(0, 217, 255, 1), 0 0 60px rgba(0, 217, 255, 0.5);
        transform: scale(1.1);
    }
    50% {
        box-shadow: 0 0 40px rgba(0, 217, 255, 1.2), 0 0 80px rgba(0, 217, 255, 0.8);
        transform: scale(1.15);
    }
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 6px;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: fit-content;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-primary);
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Thinking text - pequeno com fade out */
.thinking-text {
    font-size: 11px;
    color: var(--text-muted);
    opacity: 0.6;
    margin-top: 8px;
    padding: 4px 8px;
    font-style: italic;
    animation: fadeOut 3s ease-out forwards;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@keyframes fadeOut {
    0% {
        opacity: 0.6;
    }
    70% {
        opacity: 0.4;
    }
    100% {
        opacity: 0.2;
    }
}

.thinking-text-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Agent activity list (scrollable, Cursor-like) */
.agent-activity-list {
    margin-top: 10px;
    max-height: 50em;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}
.agent-activity-list::-webkit-scrollbar {
    width: 6px;
}
.agent-activity-list::-webkit-scrollbar-track {
    background: transparent;
}
.agent-activity-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}
.agent-activity-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.agent-activity-item {
    font-size: 13px;
    line-height: 1.4;
    color: var(--text-primary);
    padding: 3px 0;
    overflow: visible;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.agent-activity-message {
    word-break: break-word;
    white-space: normal;
}

.agent-activity-detail {
    font-size: 11px;
    color: var(--text-muted);
    word-break: break-word;
    white-space: normal;
}

.agent-activity-item-in {
    animation: agentActivityFadeIn 0.25s ease-out forwards;
}

.agent-activity-item-out {
    animation: agentActivityFadeOut 0.2s ease-in forwards;
}

@keyframes agentActivityFadeIn {
    0% {
        opacity: 0;
        transform: translateY(-4px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes agentActivityFadeOut {
    0% {
        opacity: 1;
        transform: translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateY(-2px);
    }
}

/* Persisted activity log (kept in message after response completes) */
.agent-activity-log-persisted {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color, rgba(255,255,255,0.08));
}

.agent-activity-log-persisted-heading {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

.agent-activity-list-persisted {
    max-height: 50em;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}
.agent-activity-list-persisted::-webkit-scrollbar {
    width: 6px;
}
.agent-activity-list-persisted::-webkit-scrollbar-track {
    background: transparent;
}
.agent-activity-list-persisted::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}
.agent-activity-list-persisted::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.agent-activity-list-persisted .agent-activity-item-in {
    animation: none;
}

.agent-activity-log-persisted {
    min-height: 0;
}

/* Cursor CLI terminal-style output (raw stdout/stderr) */
.chat-terminal {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    line-height: 1.45;
    background: var(--terminal-bg, #0d1117);
    color: var(--terminal-fg, #e6edf3);
    padding: 12px 14px;
    border-radius: 8px;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 70vh;
    white-space: pre-wrap;
    word-break: break-word;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
    margin: 0;
}

/* Voice Mode Overlay - bola gigante */
.voice-mode-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.voice-mode-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
}

.voice-mode-container {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    max-width: 480px;
    width: 100%;
}

.voice-mode-close {
    position: absolute;
    top: -48px;
    right: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.voice-mode-close:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
}

.voice-mode-ball {
    width: min(280px, 70vw);
    height: min(280px, 70vw);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: box-shadow 0.4s ease, transform 0.3s ease, background 0.3s ease;
    cursor: pointer;
}

.voice-mode-ball-inner {
    width: 85%;
    height: 85%;
    border-radius: 50%;
    background: var(--bg-tertiary);
    opacity: 0.6;
}

.voice-mode-ball-idle {
    background: radial-gradient(circle at 30% 30%, rgba(0, 217, 255, 0.25), rgba(0, 168, 204, 0.15));
    box-shadow: 0 0 60px rgba(0, 217, 255, 0.2), inset 0 0 40px rgba(0, 217, 255, 0.05);
}

.voice-mode-ball-idle:hover {
    box-shadow: 0 0 80px rgba(0, 217, 255, 0.3), inset 0 0 50px rgba(0, 217, 255, 0.08);
    transform: scale(1.02);
}

.voice-mode-ball-listening {
    background: radial-gradient(circle at 30% 30%, rgba(0, 217, 255, 0.5), rgba(0, 168, 204, 0.3));
    box-shadow: 0 0 80px rgba(0, 217, 255, 0.4), inset 0 0 60px rgba(0, 217, 255, 0.1);
    animation: voice-mode-pulse 1.2s ease-in-out infinite;
}

.voice-mode-ball-speaking {
    background: radial-gradient(circle at 30% 30%, rgba(0, 217, 255, 0.4), rgba(0, 168, 204, 0.25));
    box-shadow: 0 0 70px rgba(0, 217, 255, 0.35), inset 0 0 50px rgba(0, 217, 255, 0.08);
    animation: voice-mode-glow 0.8s ease-in-out infinite alternate;
}

@keyframes voice-mode-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.95; }
}

@keyframes voice-mode-glow {
    0% { box-shadow: 0 0 60px rgba(0, 217, 255, 0.3), inset 0 0 40px rgba(0, 217, 255, 0.06); }
    100% { box-shadow: 0 0 90px rgba(0, 217, 255, 0.45), inset 0 0 60px rgba(0, 217, 255, 0.1); }
}

.voice-mode-status {
    font-size: 15px;
    color: var(--text-secondary);
    text-align: center;
    min-height: 24px;
}

.voice-mode-transcript {
    width: 100%;
    max-height: 120px;
    overflow-y: auto;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.voice-mode-transcript:empty {
    display: none;
}

.voice-mode-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.voice-mode-btn {
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background 0.2s, transform 0.1s;
}

.voice-mode-listen {
    background: rgba(0, 217, 255, 0.2);
    color: var(--text-primary);
    border: 1px solid rgba(0, 217, 255, 0.4);
}

.voice-mode-listen:hover {
    background: rgba(0, 217, 255, 0.3);
}

.voice-mode-listen:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Code blocks */
code {
    background: var(--bg-tertiary);
    padding: 3px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 13px;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

pre {
    background: var(--bg-tertiary);
    padding: 16px;
    border-radius: 12px;
    overflow-x: auto;
    margin: 12px 0;
    border: 1px solid var(--border-color);
}

pre code {
    background: none;
    padding: 0;
    border: none;
    color: var(--text-primary);
}

/* Links */
a {
    color: var(--text-primary);
    text-decoration: none;
}

a:hover {
    color: var(--text-secondary);
    text-decoration: underline;
}

/* Scrollbar for sidebar */
.sidebar::-webkit-scrollbar,
.sidebar-content::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track,
.sidebar-content::-webkit-scrollbar-track {
    background: var(--bg-sidebar);
}

.sidebar::-webkit-scrollbar-thumb,
.sidebar-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover,
.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}

/* Responsive */
@media (max-width: 768px) {
    body {
        flex-direction: column;
        overflow: hidden;
    }

    .mobile-sidebar-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 99;
        opacity: 0;
        visibility: hidden;
        transition: all var(--transition-fast);
    }

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

    /* Sidebar - Escondido por padrão em mobile */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 320px;
        height: 100vh;
        max-height: 100vh;
        border-right: 1px solid var(--border-color);
        border-bottom: none;
        transform: translateX(-100%);
        z-index: 1000;
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        transition: transform var(--transition-normal);
    }

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

    .sidebar-header {
        padding: var(--space-lg) var(--space-md);
    }

    .new-chat-btn {
        padding: var(--space-sm) var(--space-md);
        font-size: 14px;
    }

    .new-chat-btn svg {
        width: 16px;
        height: 16px;
    }

    .sidebar-search {
        margin-top: var(--space-sm);
        padding: var(--space-xs) var(--space-sm);
        font-size: 14px;
    }

    .sidebar-buttons {
        margin-top: var(--space-sm);
        gap: var(--space-sm);
    }

    .settings-btn {
        height: 32px;
        padding: 0;
    }

    .settings-btn svg {
        width: 16px;
        height: 16px;
    }

    /* Main Content - Ocupa toda a tela em mobile */
    .main-content {
        width: 100%;
        height: 100vh;
        flex: 1;
        margin-left: 0;
    }

    .header {
        padding: var(--space-sm) var(--space-md);
        min-height: 52px;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .header .logo {
        font-size: 16px;
        gap: var(--space-sm);
    }
    .header .logo-brand {
        font-size: 20px;
    }
    .header .logo-ai {
        font-size: 1.3em;
    }

    .header .logo-avatar {
        width: 28px;
        height: 28px;
    }

    .header .logo-avatar svg {
        width: 20px;
        height: 20px;
    }

    .logo {
        font-size: 16px;
    }

    .logo-avatar {
        width: 32px;
        height: 32px;
    }

    .logo-avatar svg {
        width: 22px;
        height: 22px;
    }

    .header-controls {
        gap: var(--space-xs);
        padding: var(--space-xs) var(--space-sm);
        margin: calc(var(--space-xs) * -1) calc(var(--space-sm) * -1);
    }

    .model-select-wrap {
        max-width: 150px;
    }
    .model-select {
        font-size: 12px;
        height: 36px;
        padding: 0 32px 0 var(--space-sm);
        min-width: 100px;
        max-width: 150px;
    }

    .header-btn {
        width: 36px;
        height: 36px;
        padding: 0;
    }

    .header-btn svg {
        width: 16px;
        height: 16px;
    }

    .custom-model-input {
        width: 130px;
        height: 36px;
        font-size: 12px;
    }

    .cursor-usage-widget {
        height: 36px;
        padding: 0 var(--space-sm);
    }

    .container {
        padding: var(--space-md);
        height: calc(100vh - 52px);
        display: flex;
        flex-direction: column;
    }

    /* Chat empty state on mobile: centered input, transparent so star background shows; shift block up */
    .main-content.chat-empty .container {
        justify-content: center;
        align-items: center;
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        transform: translateY(-5vh);
        background: transparent;
    }

    /* Ensure star/space background is visible on mobile (full area, no clip) */
    .main-content.chat-empty .chat-empty-bg {
        position: absolute;
        inset: 0;
        z-index: 0;
        opacity: 1;
    }

    .main-content.chat-empty .input-container {
        max-width: 100%;
        margin-top: 12px;
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    #messages {
        flex: 1;
        overflow-y: auto;
        padding: 16px 0;
        margin-bottom: 16px;
    }

    .message-content {
        max-width: 95%;
        font-size: 14px;
        padding: 12px 16px;
    }

    .message.user .message-content {
        min-width: 4.5em;
    }

    .input-container {
        padding: var(--space-sm);
        gap: var(--space-xs);
        margin-top: auto;
        border-radius: var(--radius-xl);
    }

    .input-action-btn {
        padding: var(--space-xs);
        border-radius: var(--radius-md);
    }

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

    #userInput {
        padding: var(--space-sm) var(--space-md);
        font-size: 16px; /* >= 16px evita zoom automático no iOS Safari em focus */
        border-radius: var(--radius-lg);
        min-height: 44px;
    }

    #sendButton {
        padding: var(--space-sm) var(--space-lg);
        font-size: 14px;
        border-radius: var(--radius-lg);
        font-weight: 600;
    }

    .auth-page {
        padding: 20px;
        align-items: flex-start;
        padding-top: 60px;
    }
    .auth-container {
        margin: 0;
        padding: 40px 28px;
    }
}

/* Welcome message */
.welcome-message {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
}

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

.welcome-message p {
    font-size: 15px;
    color: var(--text-secondary);
}

/* Additional animations for enhanced UX */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: var(--space-xs) 0;
    align-items: center;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-primary);
    animation: typing 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: scale(1);
        opacity: 0.4;
    }
    30% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

/* Enhanced focus states for accessibility */
*:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* Subtle hover effects for interactive elements */
.message-content a:hover {
    text-decoration: underline;
    color: var(--accent-primary);
}

/* Improved scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}
