/* ====================================
   Megatek AI Assistant - Widescreen
   ==================================== */

/* CSS Variables */
:root {
    --nav-bg: #1a1f2e;
    --nav-height: 56px;
    --banner-bg: #1e2a4a;
    --bg-primary: #eef2f7;
    --bg-secondary: #ffffff;
    --bg-elevated: #f8fafc;
    --bg-user-bubble: #e8edf5;
    --bg-ai-bubble: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-nav: #cbd5e1;
    --text-nav-active: #ffffff;
    --accent-color: #dc2626;
    --accent-hover: #b91c1c;
    --accent-soft: #fee2e2;
    --border-color: #e2e8f0;
    --border-strong: #cbd5e1;
    --shadow-sm: 0 2px 10px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.1);
    --shadow-lg: 0 18px 40px rgba(15, 23, 42, 0.14);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 24px;
    --font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
    --sidebar-width: 280px;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: var(--font-family);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ====================================
   Top Navigation Bar
   ==================================== */
.top-nav {
    display: flex;
    align-items: center;
    height: var(--nav-height);
    padding: 0 24px;
    background: var(--nav-bg);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0;
    margin-right: 40px;
    flex-shrink: 0;
}

.nav-logo {
    width: 122px;
    height: 42px;
    object-fit: contain;
    display: block;
    padding: 6px 8px;
    border-radius: 6px;
    background: #ffffff;
}

.nav-brand-text {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-nav-active);
    letter-spacing: -0.01em;
}

.nav-tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 100%;
}

.nav-tab {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
    padding: 0 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-nav);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: color 0.2s;
    white-space: nowrap;
}

.nav-tab:hover {
    color: var(--text-nav-active);
}

.nav-tab.active {
    color: var(--text-nav-active);
    font-weight: 600;
}

.nav-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 16px;
    right: 16px;
    height: 3px;
    background: var(--accent-color);
    border-radius: 3px 3px 0 0;
}

.nav-actions {
    margin-left: auto;
    flex-shrink: 0;
}

.nav-user-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-nav);
    transition: background 0.2s, color 0.2s;
}

.nav-user-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    color: var(--text-nav-active);
}

/* ====================================
   Tab Panels
   ==================================== */
.tab-panel {
    display: none;
    position: fixed;
    top: var(--nav-height);
    left: 0;
    right: 0;
    bottom: 0;
}

.tab-panel.active {
    display: flex;
}

/* ====================================
   AI Chat Layout (two-column)
   ==================================== */
.ai-chat-layout {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Left Sidebar: Voice Controls */
.voice-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.voice-sidebar-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.voice-sidebar-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.voice-sidebar-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.voice-sidebar-status {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--bg-primary);
}

.voice-sidebar-status.connected {
    color: #16a34a;
    background: #f0fdf4;
}

.voice-sidebar-status.connecting {
    color: #ca8a04;
    background: #fefce8;
}

.voice-sidebar-status.error {
    color: var(--accent-color);
    background: var(--accent-soft);
}

.voice-picker-card {
    width: 100%;
    padding: 12px 12px 10px;
    border-radius: var(--radius-md);
    background: #f8fafc;
    border: 1px solid var(--border-color);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.voice-picker-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.voice-picker-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.voice-picker-current {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(220, 38, 38, 0.1);
    color: var(--accent-color);
    font-size: 12px;
    font-weight: 700;
}

.voice-picker-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: min(46vh, 420px);
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-gutter: stable;
}

.voice-option-row {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 10px;
    align-items: stretch;
}

.voice-preview-btn,
.voice-option-btn,
.mobile-voice-select {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: #ffffff;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.voice-preview-btn {
    width: 40px;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    color: var(--accent-color);
    box-shadow: var(--shadow-sm);
}

.voice-preview-btn:hover,
.voice-option-btn:hover,
.mobile-voice-select:hover {
    border-color: #93c5fd;
}

.voice-preview-btn:focus,
.voice-option-btn:focus,
.mobile-voice-select:focus {
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.14);
}

.voice-preview-btn svg {
    width: 16px;
    height: 16px;
}

.voice-preview-btn.playing {
    background: rgba(220, 38, 38, 0.1);
    border-color: rgba(220, 38, 38, 0.32);
}

.voice-option-btn {
    width: 100%;
    min-height: 42px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    text-align: left;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.voice-option-btn.is-active {
    border-color: rgba(220, 38, 38, 0.32);
    background: rgba(220, 38, 38, 0.06);
}

.voice-option-meta {
    min-width: 0;
}

.voice-option-name {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.voice-option-desc {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-secondary);
}

.voice-option-state {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-color);
}

.voice-picker-note {
    margin-top: 10px;
    font-size: 12px;
    line-height: 1.5;
    color: #64748b;
}

.voice-picker-modal {
    position: fixed;
    inset: 0;
    z-index: 250;
}

.voice-picker-modal[hidden] {
    display: none !important;
}

.voice-picker-backdrop {
    position: absolute;
    inset: 0;
    border: none;
    background: rgba(15, 23, 42, 0.54);
}

.voice-picker-sheet {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 12px;
    padding: 16px;
    border-radius: 18px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
}

.voice-picker-sheet-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.voice-picker-sheet-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.voice-picker-sheet-title {
    margin-top: 4px;
    font-size: 18px;
    line-height: 1.25;
    color: var(--text-primary);
}

.voice-picker-sheet-close {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.voice-picker-list-mobile {
    max-height: min(56vh, 420px);
    overflow-y: auto;
    padding-right: 2px;
}

.voice-sidebar-mic {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 20px 0;
}

.mic-icon {
    color: var(--accent-color);
    opacity: 0.8;
}

.voice-wave-sidebar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 32px;
}

.voice-wave-sidebar span {
    display: block;
    width: 3px;
    height: 12px;
    background: var(--text-muted);
    border-radius: 2px;
    animation: sidebarWave 1.2s ease-in-out infinite;
}

.voice-wave-sidebar span:nth-child(1)  { animation-delay: 0s; }
.voice-wave-sidebar span:nth-child(2)  { animation-delay: 0.08s; }
.voice-wave-sidebar span:nth-child(3)  { animation-delay: 0.16s; }
.voice-wave-sidebar span:nth-child(4)  { animation-delay: 0.24s; }
.voice-wave-sidebar span:nth-child(5)  { animation-delay: 0.32s; }
.voice-wave-sidebar span:nth-child(6)  { animation-delay: 0.40s; }
.voice-wave-sidebar span:nth-child(7)  { animation-delay: 0.48s; }
.voice-wave-sidebar span:nth-child(8)  { animation-delay: 0.56s; }
.voice-wave-sidebar span:nth-child(9)  { animation-delay: 0.64s; }
.voice-wave-sidebar span:nth-child(10) { animation-delay: 0.72s; }

@keyframes sidebarWave {
    0%, 100% { height: 8px; opacity: 0.4; }
    50% { height: 24px; opacity: 1; }
}

.voice-sidebar-controls {
    display: flex;
    gap: 10px;
    width: 100%;
}

.voice-ctrl-btn {
    flex: 1;
    height: 40px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
}

.voice-ctrl-btn.mute-btn {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.voice-ctrl-btn.mute-btn:hover {
    background: var(--bg-primary);
}

.voice-ctrl-btn.stop-btn {
    background: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}

.voice-ctrl-btn.stop-btn:hover {
    background: var(--accent-hover);
}

.voice-ctrl-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.voice-ctrl-btn:active:not(:disabled) {
    transform: scale(0.97);
}

/* ====================================
   Chat Main Area
   ==================================== */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-primary);
}

.chat-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 28px;
    background: var(--banner-bg);
    flex-shrink: 0;
}

.banner-logo {
    width: 112px;
    height: 38px;
    flex-shrink: 0;
    object-fit: contain;
    display: block;
    padding: 6px 8px;
    border-radius: 6px;
    background: #ffffff;
}

.banner-title {
    font-size: 17px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.01em;
}

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px 28px 16px;
    scroll-behavior: smooth;
}

.messages-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 800px;
    margin: 0 auto;
    min-height: 100%;
}

/* Message Bubbles */
.message {
    display: flex;
    flex-direction: column;
    max-width: 72%;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user {
    align-self: flex-end;
}

.message.assistant {
    align-self: flex-start;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message.user .message-bubble {
    background: #f1f5f9;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.message.assistant .message-bubble {
    background: var(--banner-bg);
    color: #e2e8f0;
    border: none;
    border-bottom-left-radius: 4px;
    box-shadow: 0 4px 16px rgba(30, 42, 74, 0.2);
}

.message.assistant .message-bubble .message-content a {
    color: #93c5fd;
    text-decoration-color: rgba(147, 197, 253, 0.4);
}

.message.assistant .message-bubble .message-content code {
    background: rgba(255, 255, 255, 0.12);
    color: #e2e8f0;
}

/* Rich Text Content in Messages */
.message-content {
    font-size: 15px;
    line-height: 1.6;
}

.message-content p {
    margin: 0 0 10px 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content strong {
    font-weight: 600;
}

.message-content ul,
.message-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

.message-content li {
    margin: 5px 0;
}

.message-content img {
    max-width: 100%;
    border-radius: var(--radius-sm);
    margin: 8px 0;
}

.message-content a {
    color: var(--accent-color);
    text-decoration: underline;
    text-decoration-color: rgba(220, 38, 38, 0.3);
    text-underline-offset: 2px;
}

.message-content a:hover {
    text-decoration-color: var(--accent-color);
}

.message-content code {
    background: var(--bg-primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
}

.message-content pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 14px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 8px 0;
}

.message-content pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}

/* Product Card Style */
.product-card {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin: 8px 0;
}

.product-card img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border-radius: 4px;
    flex-shrink: 0;
}

.product-info {
    flex: 1;
    min-width: 0;
}

.product-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.product-code {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.product-price {
    font-size: 15px;
    font-weight: 600;
    color: var(--accent-color);
    margin-bottom: 8px;
}

.product-actions {
    display: flex;
    gap: 8px;
}

.product-btn {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.product-btn.primary {
    background: var(--accent-color);
    color: white;
}

.product-btn.primary:hover {
    background: var(--accent-hover);
}

.product-btn.secondary {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.product-btn.secondary:hover {
    background: var(--border-color);
}

/* Navigation Cards */
.message-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.navigation-card {
    border: 1px solid #fecaca;
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, #fffafa 0%, #fff5f5 100%);
    padding: 12px 14px 10px;
    box-shadow: 0 6px 20px rgba(220, 38, 38, 0.06);
}

.navigation-card.has-product-link {
    cursor: pointer;
}

.navigation-card.has-product-link:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

.navigation-card.has-product-image {
    display: grid;
    grid-template-columns: 86px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
}

.navigation-card-media {
    width: 86px;
    aspect-ratio: 1;
    border: 1px solid #fee2e2;
    border-radius: var(--radius-sm);
    background: #ffffff;
    overflow: hidden;
}

.navigation-card-media img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.navigation-card-body {
    min-width: 0;
}

.navigation-card-title {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.35;
    color: var(--text-primary);
    margin-bottom: 6px;
    overflow-wrap: anywhere;
}

.navigation-card-title a {
    color: inherit;
    text-decoration: none;
}

.navigation-card-title a:hover {
    color: var(--accent-color);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.navigation-card-location {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.navigation-card-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.navigation-card-price {
    font-size: 16px;
    font-weight: 800;
    line-height: 1.2;
    color: var(--accent-color);
    min-width: 0;
}

.navigation-card-price-slot {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.navigation-card-price-slot[hidden] {
    display: none;
}

.navigation-card-price-details {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 12px;
}

.navigation-card-original-price {
    color: var(--text-secondary);
    font-weight: 600;
    text-decoration: line-through;
    text-decoration-thickness: 1.5px;
}

.navigation-card-discount {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    border-radius: var(--radius-sm);
    background: #ecfdf5;
    color: #047857;
    font-weight: 800;
    padding: 2px 7px;
}

.navigation-card-purchase-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 2px;
}

.navigation-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.crosssell-card-section {
    display: grid;
    gap: 8px;
    margin-top: 2px;
}

.crosssell-card-heading {
    font-size: 12px;
    font-weight: 800;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0;
}

.crosssell-card-grid {
    display: grid;
    gap: 10px;
}

.navigation-card.crosssell-card {
    background: var(--bg-primary);
    border-color: var(--border-color);
    box-shadow: none;
}

.navigation-btn {
    background: var(--accent-color);
    color: #fff;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 700;
    padding: 8px 14px;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.2);
}

.navigation-btn:hover {
    background: var(--accent-hover);
}

.navigation-btn:active {
    transform: scale(0.98);
}

.navigation-btn:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

.product-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
    background: #ffffff;
    color: var(--accent-color);
    font-size: 12px;
    font-weight: 700;
    padding: 8px 12px;
    text-decoration: none;
    transition: border-color 0.2s, background 0.2s;
}

.product-page-btn:hover {
    background: #fff5f5;
    border-color: var(--accent-color);
}

/* Category Card */
.category-card {
    padding: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin: 8px 0;
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.category-title {
    font-weight: 600;
    font-size: 14px;
}

.category-items {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.category-item {
    flex-shrink: 0;
    width: 60px;
    text-align: center;
}

.category-item img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 4px;
    margin: 0;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 16px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    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; }
}

/* ====================================
   Input Area
   ==================================== */
.input-area {
    padding: 12px 28px 16px;
    background: linear-gradient(180deg, rgba(238,242,247,0) 0%, var(--bg-primary) 30%);
    flex-shrink: 0;
}

.attachment-preview-container {
    display: flex;
    margin-bottom: 10px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.attachment-preview {
    position: relative;
    width: 72px;
    height: 72px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.attachment-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.attachment-remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 14px;
    line-height: 20px;
    cursor: pointer;
}

.input-wrapper {
    display: flex;
    align-items: center;
    background: #ffffff;
    border-radius: var(--radius-lg);
    padding: 5px 5px 5px 18px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
    transition: border-color 0.2s, box-shadow 0.2s;
    max-width: 800px;
    margin: 0 auto;
}

.input-wrapper:focus-within {
    border-color: #93c5fd;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.12);
}

.message-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 15px;
    font-family: inherit;
    color: var(--text-primary);
    outline: none;
    padding: 8px 0;
}

.message-input::placeholder {
    color: var(--text-muted);
}

.attach-btn {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: 50%;
    transition: all 0.2s;
    flex-shrink: 0;
    margin-right: 4px;
}

.attach-btn:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.send-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-color);
    border: none;
    cursor: pointer;
    color: white;
    border-radius: 50%;
    transition: all 0.2s;
    flex-shrink: 0;
}

.send-btn:hover {
    background: var(--accent-hover);
}

.send-btn:active {
    transform: scale(0.95);
}

.send-btn:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
}

/* Voice Button */
.voice-btn {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--accent-color);
    border-radius: 50%;
    transition: all 0.2s;
    flex-shrink: 0;
    margin-right: 4px;
}

.voice-btn:hover {
    background: rgba(220, 38, 38, 0.08);
}

.voice-btn:active,
.voice-btn.recording {
    background: var(--accent-color);
    color: white;
    transform: scale(1.1);
}

.voice-btn.recording {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.35); }
    50% { box-shadow: 0 0 0 12px rgba(220, 38, 38, 0); }
}

/* Voice Recording Overlay */
.voice-recording-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.voice-recording-overlay.active {
    display: flex;
}

.voice-recording-indicator {
    text-align: center;
    color: white;
    padding: 32px 52px;
    border-radius: var(--radius-md);
    background: rgba(220, 38, 38, 0.92);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.voice-wave {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 48px;
    margin-bottom: 16px;
}

.voice-wave span {
    display: block;
    width: 4px;
    height: 20px;
    background: white;
    border-radius: 2px;
    animation: wave 1s ease-in-out infinite;
}

.voice-wave span:nth-child(1) { animation-delay: 0s; }
.voice-wave span:nth-child(2) { animation-delay: 0.1s; }
.voice-wave span:nth-child(3) { animation-delay: 0.2s; }
.voice-wave span:nth-child(4) { animation-delay: 0.3s; }
.voice-wave span:nth-child(5) { animation-delay: 0.4s; }

@keyframes wave {
    0%, 100% { height: 20px; }
    50% { height: 40px; }
}

.voice-recording-text {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.voice-recording-hint {
    font-size: 14px;
    opacity: 0.8;
}

/* Transcribing state */
.voice-btn.transcribing {
    background: var(--accent-color);
    color: white;
    animation: transcribe-pulse 0.8s infinite;
}

@keyframes transcribe-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.message.assistant .message-bubble .message-content pre {
    background: #111827;
}

/* Loading State */
.message.loading .message-bubble {
    background: transparent;
    box-shadow: none;
    border: none;
    padding: 8px 0;
}

/* Error State */
.message.error .message-bubble {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

/* ====================================
   Product Search Page
   ==================================== */
.search-page {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.search-header {
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 24px 32px 20px;
}

.search-header-inner {
    max-width: 1200px;
    margin: 0 auto;
}

.search-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.search-bar-row {
    display: flex;
    gap: 12px;
    width: 100%;
    max-width: 780px;
}

.search-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    height: 46px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input-wrapper:focus-within {
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-icon {
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 15px;
    font-family: inherit;
    color: var(--text-primary);
    outline: none;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-clear-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.15s;
    flex-shrink: 0;
}

.search-clear-btn:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.search-submit-btn {
    height: 46px;
    padding: 0 28px;
    background: var(--accent-color);
    color: #fff;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    flex-shrink: 0;
}

.search-submit-btn:hover {
    background: var(--accent-hover);
}

.search-submit-btn:active {
    transform: scale(0.97);
}

.search-submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.search-mode-hint {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-muted);
}

.search-mode-hint strong {
    color: var(--text-secondary);
    font-weight: 600;
}

.search-stats {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.search-stats-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.search-stats-item svg {
    opacity: 0.5;
    flex-shrink: 0;
}

/* Search Results Area */
.search-results-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
}

.search-empty,
.search-loading,
.search-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 80px 20px;
    text-align: center;
    color: var(--text-secondary);
}

.search-empty[hidden],
.search-loading[hidden],
.search-error[hidden],
.search-results-container[hidden] {
    display: none;
}

.search-empty svg,
.search-error svg {
    color: var(--text-muted);
    opacity: 0.5;
}

.search-empty h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.search-empty p,
.search-error p {
    font-size: 15px;
    max-width: 400px;
    line-height: 1.6;
}

.search-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Results Meta */
.search-results-meta {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 16px;
    font-size: 14px;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

#searchResultCount {
    font-weight: 700;
    color: var(--text-primary);
}

.search-results-query {
    color: var(--text-muted);
}

/* Results Table */
.search-table-wrap {
    max-width: 1200px;
    margin: 0 auto;
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
}

.search-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    white-space: nowrap;
}

.search-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

.search-table th {
    padding: 10px 14px;
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-color);
}

.search-table td {
    padding: 10px 14px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.search-table tbody tr:last-child td {
    border-bottom: none;
}

.search-table tbody tr:hover {
    background: rgba(59, 130, 246, 0.04);
}

.col-code { min-width: 100px; }
.col-desc { min-width: 220px; white-space: normal; }
.col-desc-alb { min-width: 200px; white-space: normal; }
.col-url { min-width: 92px; }
.col-brand { min-width: 100px; }
.col-price { min-width: 80px; text-align: right; }
.col-discount { min-width: 110px; text-align: right; }
.col-stock { min-width: 70px; text-align: right; }
.col-location { min-width: 120px; }

.search-table td.col-price,
.search-table th.col-price {
    text-align: right;
}

.search-table td.col-discount,
.search-table th.col-discount {
    text-align: right;
}

.search-table td.col-stock,
.search-table th.col-stock {
    text-align: right;
}

.td-code {
    font-family: 'Consolas', 'Monaco', monospace;
    font-weight: 600;
    color: var(--accent-color);
    font-size: 13px;
}

.td-price {
    font-weight: 600;
}

.td-original-price {
    color: var(--text-muted);
}

.price-old {
    text-decoration: line-through;
    text-decoration-thickness: 1.5px;
    text-underline-offset: 2px;
}

.discount-badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: var(--radius-sm);
    background: #ecfdf5;
    color: #047857;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 8px;
    white-space: nowrap;
}

.original-price {
    color: var(--text-muted);
}

.td-url {
    font-size: 13px;
}

.product-url-link {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    color: var(--accent-color);
    font-weight: 700;
    text-decoration: none;
}

.product-url-link:hover {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.td-stock {
    font-weight: 500;
}

.stock-zero {
    color: var(--text-muted);
}

.stock-low {
    color: #ca8a04;
}

.stock-ok {
    color: #16a34a;
}

.td-location {
    font-size: 12px;
    color: var(--text-secondary);
}

.td-desc {
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.td-code-match {
    font-size: 14px;
}

mark {
    background: #fef08a;
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}

/* ====================================
   Mobile Voice Bar (hidden on desktop)
   ==================================== */
.mobile-voice-bar {
    display: none;
}

.mobile-voice-select {
    display: none;
}

/* ====================================
   Mobile Search Cards (hidden on desktop)
   ==================================== */
.search-cards {
    display: none;
}

/* ====================================
   Responsive: narrow screens
   ==================================== */
@media (max-width: 900px) {
    .voice-sidebar {
        display: none;
    }

    .messages-list {
        max-width: 100%;
    }

    .input-wrapper {
        max-width: 100%;
    }

    .attachment-preview-container {
        max-width: 100%;
    }
}

@media (max-width: 600px) {
    .top-nav {
        gap: 8px;
        padding: 0 10px;
    }

    .nav-brand {
        gap: 8px;
        margin-right: 0;
        min-width: 0;
    }

    .nav-brand-text {
        font-size: 16px;
    }

    .nav-tabs {
        flex: 1;
        min-width: 0;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .nav-tabs::-webkit-scrollbar {
        display: none;
    }

    .nav-tab {
        flex: 0 0 auto;
        padding: 0 12px;
        font-size: 13px;
    }

    .nav-actions {
        display: none;
    }

    .chat-banner {
        display: none;
    }

    .messages-container {
        padding: 14px 12px 10px;
    }

    .message {
        max-width: 92%;
    }

    .message-bubble {
        padding: 10px 14px;
    }

    /* ---- Mobile Voice Bar ---- */
    .mobile-voice-bar {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr);
        grid-template-areas:
            "mic label wave"
            "picker talk stop";
        align-items: center;
        column-gap: 8px;
        row-gap: 10px;
        padding: 8px 12px;
        margin-bottom: 8px;
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        max-width: 100%;
        overflow: hidden;
    }

    .mobile-voice-mic {
        color: var(--accent-color);
        flex-shrink: 0;
        grid-area: mic;
    }

    .mobile-voice-label {
        grid-area: label;
        font-size: 13px;
        font-weight: 600;
        color: var(--text-primary);
        min-width: 0;
        line-height: 1.2;
    }

    .mobile-voice-status {
        display: none;
    }

    .mobile-voice-wave {
        grid-area: wave;
        display: flex;
        align-items: center;
        gap: 2px;
        height: 20px;
        min-width: 44px;
        justify-content: flex-end;
        justify-self: end;
    }

    .mobile-voice-wave span {
        display: block;
        width: 2px;
        height: 8px;
        background: var(--text-muted);
        border-radius: 1px;
        animation: mobileWave 1.2s ease-in-out infinite;
    }

    .mobile-voice-wave span:nth-child(1) { animation-delay: 0s; }
    .mobile-voice-wave span:nth-child(2) { animation-delay: 0.1s; }
    .mobile-voice-wave span:nth-child(3) { animation-delay: 0.2s; }
    .mobile-voice-wave span:nth-child(4) { animation-delay: 0.3s; }
    .mobile-voice-wave span:nth-child(5) { animation-delay: 0.4s; }

    @keyframes mobileWave {
        0%, 100% { height: 6px; opacity: 0.4; }
        50% { height: 16px; opacity: 1; }
    }

    .mobile-voice-btn {
        width: 100%;
        min-width: 0;
        min-height: 38px;
        padding: 6px 16px;
        font-size: 13px;
        font-weight: 600;
        border-radius: var(--radius-sm);
        border: 1px solid var(--border-color);
        cursor: pointer;
        transition: all 0.2s;
    }

    .mobile-voice-btn.talk {
        grid-area: talk;
        background: var(--bg-secondary);
        color: var(--text-primary);
    }

    .mobile-voice-btn.talk:hover {
        background: var(--bg-primary);
    }

    .mobile-voice-btn.stop {
        grid-area: stop;
        background: var(--accent-color);
        color: #fff;
        border-color: var(--accent-color);
    }

    .mobile-voice-btn.stop:hover {
        background: var(--accent-hover);
    }

    .mobile-voice-btn:disabled {
        opacity: 0.4;
        cursor: not-allowed;
    }

    .mobile-voice-select {
        grid-area: picker;
        display: block;
        max-width: none;
        min-width: 0;
        height: 38px;
        padding: 0 12px;
        font-size: 12px;
        width: 100%;
    }

    /* ---- Input Area ---- */
    .input-area {
        padding: 8px 12px 12px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .input-wrapper {
        padding: 4px 4px 4px 14px;
    }

    .message-input {
        font-size: 16px;
    }

    /* ---- Search Page ---- */
    .search-header {
        padding: 16px 16px 14px;
    }

    .search-title {
        font-size: 20px;
        margin-bottom: 12px;
    }

    .search-bar-row {
        flex-direction: column;
        max-width: 100%;
    }

    .search-submit-btn {
        width: 100%;
        border-radius: var(--radius-lg);
        height: 44px;
        font-size: 15px;
    }

    .search-mode-hint {
        display: none;
    }

    .search-results-area {
        padding: 12px 16px;
    }

    .search-results-meta {
        margin-bottom: 12px;
    }

    .search-table-wrap {
        display: none;
    }

    .search-cards {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    /* ---- Product Card ---- */
    .search-card {
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-sm);
        padding: 14px 16px;
    }

    .search-card-code {
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--text-muted);
        margin-bottom: 4px;
    }

    .search-card-desc {
        font-size: 15px;
        font-weight: 600;
        color: var(--text-primary);
        line-height: 1.4;
        margin-bottom: 12px;
        word-wrap: break-word;
    }

    .search-card-links {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        margin: -2px 0 12px;
    }

    .search-card-meta {
        display: flex;
        gap: 0;
    }

    .search-card-meta-item {
        flex: 1;
    }

    .search-card-meta-label {
        font-size: 10px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--text-muted);
        margin-bottom: 2px;
    }

    .search-card-meta-value {
        font-size: 16px;
        font-weight: 700;
        color: var(--text-primary);
    }

    .search-card-meta-value.location {
        font-size: 13px;
        font-weight: 500;
        color: var(--text-secondary);
    }

    .search-empty,
    .search-loading,
    .search-error {
        padding: 60px 16px;
    }

    .search-empty h2 {
        font-size: 18px;
    }

    /* ---- Navigation Card mobile tweaks ---- */
    .navigation-card {
        padding: 10px 12px 8px;
    }

    .navigation-card.has-product-image {
        grid-template-columns: 72px minmax(0, 1fr);
        gap: 10px;
    }

    .navigation-card-media {
        width: 72px;
    }

    .navigation-card-purchase-row {
        gap: 10px;
    }

    .navigation-card-actions {
        flex-direction: row;
    }

    .navigation-btn {
        text-align: center;
        padding: 10px 12px;
        font-size: 13px;
    }
}

@media (max-width: 420px) {
    .top-nav {
        padding: 0 8px;
    }

    .nav-brand-text {
        font-size: 15px;
    }

    .nav-tab {
        padding: 0 10px;
        font-size: 12px;
    }

    .mobile-voice-bar {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        grid-template-areas:
            "mic wave"
            "label label"
            "picker picker"
            "talk stop";
    }

    .mobile-voice-label {
        font-size: 12px;
    }

    .mobile-voice-btn,
    .mobile-voice-select {
        font-size: 12px;
    }
}

/* ====================================
   Dark mode support
   ==================================== */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #0f1219;
        --bg-secondary: #161b26;
        --bg-elevated: #1c2333;
        --bg-user-bubble: #1f2a44;
        --bg-ai-bubble: #161b26;
        --text-primary: #e2e8f0;
        --text-secondary: #93a4c0;
        --text-muted: #64748b;
        --border-color: #243248;
        --border-strong: #334155;
        --banner-bg: #111827;
        --nav-bg: #0d1017;
    }

    .message-content code {
        background: #2d3748;
    }

    .input-wrapper {
        background: #1c2333;
    }

    .voice-sidebar {
        background: #131820;
    }

    .search-input-wrapper {
        background: #1c2333;
    }

    .search-table-wrap {
        background: #161b26;
        border-color: #243248;
    }

    .search-table th {
        background: #111827;
    }

    .search-table tbody tr:hover {
        background: rgba(59, 130, 246, 0.08);
    }

    mark {
        background: #854d0e;
        color: #fef08a;
    }

    .navigation-card {
        background: linear-gradient(180deg, #1a1012 0%, #1f1215 100%);
        border-color: #5c2020;
    }

    .navigation-card-media {
        background: #111827;
        border-color: #5c2020;
    }

    .nav-user-btn {
        background: rgba(255, 255, 255, 0.06);
    }

    .mobile-voice-bar {
        background: #1c2333;
        border-color: #243248;
    }

    .voice-picker-card {
        background: #1c2333;
        border-color: #2f3c51;
    }

    .voice-picker-current {
        background: rgba(220, 38, 38, 0.18);
        color: #fecaca;
    }

    .voice-preview-btn,
    .voice-option-btn,
    .mobile-voice-select {
        background: #1c2333;
        border-color: #334155;
    }

    .voice-option-btn.is-active,
    .voice-preview-btn.playing {
        background: rgba(220, 38, 38, 0.14);
        border-color: rgba(248, 113, 113, 0.34);
    }

    .voice-option-name,
    .voice-picker-sheet-title,
    .voice-picker-sheet-close {
        color: #e5e7eb;
    }

    .voice-option-desc,
    .voice-picker-sheet-label {
        color: #94a3b8;
    }

    .voice-picker-sheet {
        background: #131820;
        border-color: #2f3c51;
    }

    .voice-picker-backdrop {
        background: rgba(2, 6, 23, 0.72);
    }

    .search-card {
        background: #161b26;
        border-color: #243248;
    }
}

/* ====================================
   Print styles
   ==================================== */
@media print {
    .top-nav,
    .voice-sidebar,
    .input-area {
        display: none;
    }

    .messages-container {
        overflow: visible;
    }

    .tab-panel {
        position: static;
    }
}
