/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: #2B5F7F;
    background: #B8E6E8;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    min-height: 100vh;
    background: #B8E6E8;
    box-shadow: none;
}

/* Landing Page */
.landing-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    text-align: center;
}

.logo-title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 1rem;
    animation: fadeInDown 0.6s ease-out;
}

.logo-title-container h1 {
    font-size: 2.5rem;
    font-weight: 400;
    color: #2B5F7F;
    margin: 0;
    letter-spacing: 0.5px;
    line-height: 1;
}

.logo-title-container .logo-icon {
    height: 2.5rem;
    width: auto;
    opacity: 0.7;
}

.description {
    font-size: 1.125rem;
    color: #3B7FA5;
    margin-bottom: 3rem;
    max-width: 400px;
    animation: fadeInUp 0.6s ease-out 0.2s both;
}

.instructions {
    background: rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 3rem;
    width: 100%;
    max-width: 350px;
    animation: fadeInUp 0.6s ease-out 0.3s both;
}

.instruction-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 0;
}

.instruction-item:not(:last-child) {
    border-bottom: 1px solid rgba(59, 127, 165, 0.2);
}

.step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #7DD3D3;
    color: #2B5F7F;
    border-radius: 50%;
    font-weight: 600;
    margin-right: 1rem;
    flex-shrink: 0;
}

.step-text {
    text-align: left;
    color: #2B5F7F;
}

/* Buttons */
.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: #7DD3D3;
    color: #2B5F7F;
    border: none;
    padding: 1rem 3rem;
    font-size: 1.125rem;
    font-weight: 600;
    border-radius: 24px;
    cursor: pointer;
    min-height: 48px;
    min-width: 48px;
    transition: all 0.2s;
    animation: fadeInUp 0.6s ease-out 0.4s both;
}

.btn-primary:hover {
    background: #6BC5C5;
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(125, 211, 211, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: #e5e7eb;
    color: #374151;
    border: none;
    padding: 0.875rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    min-height: 44px;
    min-width: 100px;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #d1d5db;
}

.btn-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #3B7FA5;
    transition: all 0.2s;
    border-radius: 8px;
}

.btn-icon:hover {
    background: rgba(125, 211, 211, 0.2);
}

.btn-plus {
    background: transparent;
    color: white;
    border: none;
    padding: 8px;
    border-radius: 0;
    cursor: pointer;
    min-height: 40px;
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-plus:hover {
    opacity: 0.8;
}

.btn-send {
    background: #7DD3D3;
    color: #2B5F7F;
    border: none;
    padding: 12px;
    border-radius: 24px;
    cursor: pointer;
    min-height: 48px;
    min-width: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-send:hover:not(:disabled) {
    background: #6BC5C5;
}

.btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Scanner Page */
.scan-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: none;
}

.page-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 30px 20px 60px 20px;
}

.page-title h2 {
    font-size: 2.5rem;
    font-weight: 400;
    color: #2B5F7F;
    letter-spacing: 0.5px;
    line-height: 1;
    margin: 0;
}

.page-title .page-logo-icon {
    height: 2.5rem;
    width: auto;
    opacity: 0.7;
}

.scanner {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    margin: 1rem;
    border-radius: 12px;
    overflow: hidden;
    min-height: 400px;
}

.scan-instruction {
    text-align: center;
    color: #6b7280;
    padding: 1rem;
    font-size: 1rem;
}

.error-message {
    background: #fee2e2;
    color: #dc2626;
    padding: 1rem;
    margin: 1rem;
    border-radius: 8px;
    text-align: center;
}

.footer {
    padding: 1rem;
    border-top: 1px solid #e5e7eb;
}

/* Chat Page */
.chat-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    display: flex;
    animation: messageSlideIn 0.3s ease-out;
}

.message.user {
    justify-content: flex-end;
}

.message.assistant {
    justify-content: flex-start;
}

.message-content {
    max-width: 70%;
    padding: 14px 16px;
    border-radius: 20px;
    word-wrap: break-word;
    font-size: 18px;
    line-height: 1.4;
}

.message.user .message-content {
    background: rgba(125, 211, 211, 0.6);
    color: #2B5F7F;
    white-space: pre-wrap;
}

.message.assistant .message-content {
    background: rgba(255, 255, 255, 0.5);
    color: #3B7FA5;
}

/* Markdown styling within messages */
.message-content p {
    margin: 0 0 0.5em 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul,
.message-content ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.message-content li {
    margin: 0.25em 0;
}

.message-content strong {
    font-weight: 600;
}

.message-content em {
    font-style: italic;
}

.message-content code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
}

.message-content pre {
    background: rgba(0, 0, 0, 0.1);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0.5em 0;
}

.message-content pre code {
    background: none;
    padding: 0;
}

.message-content a {
    color: #2B5F7F;
    text-decoration: underline;
}

.message-content a:hover {
    color: #1E4B60;
}

.message-content h1,
.message-content h2,
.message-content h3 {
    margin: 0.5em 0 0.3em 0;
    font-weight: 600;
}

.message-content h1 {
    font-size: 1.3em;
}

.message-content h2 {
    font-size: 1.2em;
}

.message-content h3 {
    font-size: 1.1em;
}

.message-content blockquote {
    border-left: 3px solid rgba(43, 95, 127, 0.3);
    padding-left: 12px;
    margin: 0.5em 0;
    color: rgba(43, 95, 127, 0.8);
}

.loading-message {
    text-align: center;
    color: #3B7FA5;
    padding: 2rem;
    font-size: 14px;
}

.message.loading {
    justify-content: flex-start;
}

.message.loading .message-content {
    background: transparent;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.typing-indicator {
    display: inline-flex;
    gap: 2px;
}

.typing-indicator span {
    animation: typingDot 1.4s infinite;
    font-size: 1.5rem;
    line-height: 1;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

.input-area {
    display: flex;
    gap: 8px;
    padding: 16px 20px 32px 20px;
    border-top: none;
    background: transparent;
}

#message-input {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 24px;
    font-size: 16px;
    outline: none;
    transition: box-shadow 0.2s;
    background: white;
    height: 48px;
    color: #2B5F7F;
}

#message-input::placeholder {
    color: rgba(59, 127, 165, 0.5);
}

#message-input:focus {
    box-shadow: 0 2px 8px rgba(43, 95, 127, 0.1);
}

#message-input:disabled {
    background: rgba(255, 255, 255, 0.5);
    cursor: not-allowed;
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes typingDot {
    0%, 60%, 100% {
        opacity: 0.3;
    }
    30% {
        opacity: 1;
    }
}

/* Mobile Optimizations */
@media (max-width: 640px) {
    .logo-title-container h1 {
        font-size: 2rem;
    }

    .logo-title-container .logo-icon {
        height: 2rem;
    }

    .page-title h2 {
        font-size: 2rem;
    }

    .page-title .page-logo-icon {
        height: 2rem;
    }

    .description {
        font-size: 1rem;
    }

    .message-content {
        max-width: 75%;
        font-size: 16px;
    }
}

/* Dark mode scanner */
#reader video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
