/* Ubiken - Dark Mode Premium Styles */
:root {
    --bg-primary: #0a0a0b;
    --bg-secondary: #141416;
    --bg-tertiary: #1c1c1f;
    --surface: #242428;
    --surface-hover: #2a2a2f;
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --accent: #22c55e;
    --accent-dim: rgba(34, 197, 94, 0.15);
    --danger: #ef4444;
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --font-sans: 'Inter', -apple-system, sans-serif;
}

/* Reset completo */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
    max-width: 100%;
    overflow: hidden;
    -webkit-text-size-adjust: 100%;
}

body {
    height: 100%;
    max-width: 100%;
    overflow: hidden;
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
}

/* App container - viewport limitado */
.app {
    height: 100%;
    max-width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    padding-top: env(safe-area-inset-top);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 18px;
}

.logo-icon {
    font-size: 20px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background 0.3s;
}

.status-indicator.active .status-dot {
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
}

.status-indicator.error .status-dot {
    background: var(--danger);
}

/* Search Container */
.search-container {
    padding: 0 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-shrink: 0;
}

/* Glassmorphism Search Bar */
.glass-effect {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
}

.search-bar {
    display: flex;
    align-items: center;
    padding: 14px 18px;
    gap: 12px;
    transition: all 0.2s;
    max-width: 100%;
}

.search-bar:focus-within {
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

.search-icon {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-bar input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: 16px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-width: 0;
    width: 100%;
}

.search-bar input::placeholder {
    color: var(--text-muted);
}

.mic-btn {
    background: var(--surface);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.mic-btn svg {
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
}

.mic-btn:active {
    transform: scale(0.95);
    background: var(--surface-hover);
}

/* Location Badge - tamaño fijo */
.location-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    font-size: 12px;
    color: var(--text-secondary);
    width: fit-content;
    position: relative;
}

.location-badge.active {
    color: var(--accent);
}

/* Pulse ring - tamaño fijo de 20px */
.pulse-ring {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: transparent;
}

.pulse-ring::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    z-index: 1;
}

.location-badge.active .pulse-ring::before {
    background: var(--accent);
}

.location-badge.active .pulse-ring {
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0;
        transform: translateY(-50%) scale(0.5);
    }

    50% {
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }
}

/* Results Container */
.results-container {
    flex: 1;
    padding: 0 16px;
    overflow-y: auto;
    max-width: 100%;
}

/* Skeleton Loading */
.skeleton-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.skeleton-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 100%;
    overflow: hidden;
}

.skeleton-line {
    height: 14px;
    background: linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 50%, var(--surface) 75%);
    background-size: 200% 100%;
    border-radius: 4px;
    animation: shimmer 1.5s infinite;
    max-width: 100%;
}

.skeleton-line.wide {
    width: 70%;
}

.skeleton-line.medium {
    width: 50%;
}

.skeleton-line.narrow {
    width: 35%;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

/* Result Cards */
.results-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 100%;
}

.result-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all 0.2s;
    border: 1px solid transparent;
    max-width: 100%;
    overflow: hidden;
}

.result-card:active {
    background: var(--surface);
    transform: scale(0.98);
}

.result-card.best {
    border-color: var(--accent);
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--accent-dim) 100%);
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.result-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary);
    word-break: break-word;
}

.result-category {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.result-price {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent);
    flex-shrink: 0;
}

.result-meta {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.result-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.result-meta svg {
    width: 14px;
    height: 14px;
    opacity: 0.7;
}

.route-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    max-width: 100%;
    font-family: var(--font-sans);
    text-decoration: none;
}

.route-btn:active {
    background: var(--surface-hover);
    transform: scale(0.98);
}

.route-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* AI Recommendation */
.ai-recommendation {
    margin: 16px;
    padding: 16px 18px;
    border-radius: var(--radius-lg);
    max-width: 100%;
}

/* Empty & Error States */
.empty-state,
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    gap: 12px;
}

.empty-icon,
.error-icon {
    font-size: 40px;
    margin-bottom: 8px;
}

.empty-state p,
.error-state p {
    color: var(--text-muted);
    font-size: 14px;
}

.retry-btn {
    margin-top: 8px;
    padding: 10px 20px;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    font-family: var(--font-sans);
}

/* Footer */
.footer {
    padding: 24px;
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-card {
    animation: fadeIn 0.3s ease-out forwards;
}

.result-card:nth-child(1) {
    animation-delay: 0ms;
}

.result-card:nth-child(2) {
    animation-delay: 50ms;
}

.result-card:nth-child(3) {
    animation-delay: 100ms;
}

/* Mobile First - phones in portrait */
@media (max-width: 480px) {
    .search-container {
        padding: 0 12px 20px;
    }

    .results-container {
        padding: 0 12px;
    }

    .result-price {
        font-size: 20px;
    }

    .result-header {
        flex-wrap: wrap;
    }
}

/* Tablet+ */
@media (min-width: 768px) {
    .search-container {
        max-width: 600px;
        margin: 0 auto;
        padding-bottom: 32px;
    }

    .results-container {
        max-width: 600px;
        margin: 0 auto;
    }

    .result-card {
        padding: 20px;
    }
}

/* Header Actions & Merchant Button */
.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.merchant-btn {
    background: var(--accent);
    color: #000;
    border: none;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-sans);
}

.merchant-btn:active {
    transform: scale(0.95);
    background: #1ea34d;
}

/* Chat Modal */
.chat-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease-out forwards;
}

.chat-modal[hidden] {
    display: none;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--glass-border);
    flex-shrink: 0;
}

.chat-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 16px;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    padding: 0 8px;
    transition: color 0.2s;
}

.close-btn:active {
    color: var(--text-primary);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    display: flex;
    max-width: 85%;
    animation: fadeIn 0.3s ease-out;
}

.message.user {
    align-self: flex-end;
}

.message.bot {
    align-self: flex-start;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    line-height: 1.4;
    word-break: break-word;
}

.message.user .message-bubble {
    background: var(--accent);
    color: #000;
    border-bottom-right-radius: 4px;
}

.message.bot .message-bubble {
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-bottom-left-radius: 4px;
}

.chat-input-area {
    padding: 12px 16px;
    display: flex;
    gap: 12px;
    margin: 16px;
    align-items: center;
}

.chat-input-area input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 15px;
    font-family: var(--font-sans);
}

.chat-input-area input::placeholder {
    color: var(--text-muted);
}

.send-btn {
    background: var(--surface-hover);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.send-btn:active {
    transform: scale(0.95);
    background: var(--surface);
}

.send-btn svg {
    width: 18px;
    height: 18px;
}

@media (min-width: 768px) {
    .chat-modal {
        top: auto;
        left: auto;
        right: 24px;
        bottom: 24px;
        width: 380px;
        height: 600px;
        border-radius: var(--radius-xl);
        border: 1px solid var(--glass-border);
        box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    }
}

/* Main Chat UI */
.main-chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 70px);
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    padding: 0 16px;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
    padding-bottom: 120px;
}

.chat-history::-webkit-scrollbar {
    width: 6px;
}
.chat-history::-webkit-scrollbar-thumb {
    background: var(--surface);
    border-radius: 10px;
}

.chat-input-wrapper {
    position: absolute;
    bottom: 24px;
    left: 16px;
    right: 16px;
    z-index: 10;
}

.chat-location-badge {
    position: absolute;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

/* Reusing modal chat message bubbles for main chat */
.main-chat-container .message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: fadeIn 0.3s ease forwards;
}

.main-chat-container .message.bot {
    align-self: flex-start;
}

.main-chat-container .message.user {
    align-self: flex-end;
}

.main-chat-container .message-bubble {
    padding: 14px 18px;
    border-radius: 20px;
    font-size: 15px;
    line-height: 1.5;
    word-break: break-word;
}

.main-chat-container .bot .message-bubble {
    background: var(--surface);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--glass-border);
}

.main-chat-container .user .message-bubble {
    background: var(--accent);
    color: #000;
    border-bottom-right-radius: 4px;
    font-weight: 500;
}

/* Result Cards in Chat */
.chat-result-card {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.chat-result-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 16px;
}
.chat-result-price {
    color: var(--accent);
    font-size: 18px;
    font-weight: 700;
}
.chat-result-meta {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    gap: 8px;
}