/* ============================================
   ORITO CHATBOT STYLES
   Desktop-only chatbot widget
   ============================================ */

/* Chat Icon Button - Fixed at bottom-right */
#orito-chat-icon {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 180px;
    cursor: pointer;
    z-index: 9998;
    transition: transform 0.3s ease, opacity 0.3s ease, box-shadow 0.3s ease;
    background-color: #FBF6F3;
    background-image: 
        /* Paper fiber texture */
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 1px,
            rgba(0, 0, 0, 0.012) 1px,
            rgba(0, 0, 0, 0.012) 2px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 1px,
            rgba(0, 0, 0, 0.01) 1px,
            rgba(0, 0, 0, 0.01) 2px
        ),
        /* Subtle diagonal wrinkle lines */
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.015) 2px,
            rgba(0, 0, 0, 0.015) 4px
        ),
        /* Organic noise texture */
        radial-gradient(
            ellipse at 20% 30%,
            rgba(255, 255, 255, 0.25) 0%,
            transparent 50%
        ),
        radial-gradient(
            ellipse at 80% 70%,
            rgba(0, 0, 0, 0.05) 0%,
            transparent 50%
        );
    border: 1px solid rgba(45, 45, 45, 0.15);
    border-radius: 20px;
    padding: 16px;
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.1),
        0 6px 12px rgba(0, 0, 0, 0.08),
        inset 0 0 30px rgba(255, 255, 255, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.8),
        inset 0 0 0 1px rgba(45, 45, 45, 0.03);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    overflow: hidden;
    transform: rotate(-0.5deg);
}

/* Paper grain overlay */
#orito-chat-icon::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background-image: 
        url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200"><filter id="cardGrain"><feTurbulence type="fractalNoise" baseFrequency="0.85" numOctaves="5" seed="3" /></filter><rect width="200" height="200" filter="url(%23cardGrain)" opacity="0.4"/></svg>'),
        radial-gradient(circle at 30% 40%, rgba(255,255,255,0.4) 0%, transparent 60%),
        radial-gradient(circle at 70% 60%, rgba(45,45,45,0.015) 0%, transparent 50%);
    background-size: 150px 150px, 300px 300px, 250px 250px;
    opacity: 0.35;
    mix-blend-mode: overlay;
    pointer-events: none;
    z-index: 0;
}

/* Paper corner curl */
#orito-chat-icon::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 40px;
    height: 40px;
    background: 
        linear-gradient(135deg, transparent 40%, rgba(0,0,0,0.04) 50%, rgba(0,0,0,0.02) 100%);
    border-bottom-right-radius: inherit;
    opacity: 0.5;
    pointer-events: none;
    z-index: 1;
}

#orito-chat-icon.hidden {
    opacity: 0;
    pointer-events: none;
}

.orito-icon-header {
    text-align: center;
    width: 100%;
    position: relative;
    z-index: 2;
}

.orito-icon-title {
    font-size: 14px;
    color: #2D2D2D;
    margin: 0 0 4px 0;
    font-weight: 400;
    font-family: 'Inter', system-ui, sans-serif;
    text-shadow: 
        0 0.5px 0.8px rgba(45, 45, 45, 0.06),
        0 0.8px 1.2px rgba(45, 45, 45, 0.04);
}

.orito-icon-name {
    font-size: 28px;
    font-weight: 700;
    color: #2D2D2D;
    margin: 0;
    font-family: 'Playfair Display', Georgia, serif;
    line-height: 1.2;
    text-shadow: 
        0 0.5px 1px rgba(45, 45, 45, 0.08),
        0 1px 2px rgba(45, 45, 45, 0.05),
        0 0 8px rgba(45, 45, 45, 0.02);
    letter-spacing: -0.01em;
}

.orito-icon-avatar {
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
}

.orito-icon-avatar img {
    width: 130%;
    height: 130%;
    object-fit: contain;
    filter: drop-shadow(2px 2px 4px rgba(45, 45, 45, 0.1));
}

.orito-icon-cta {
    background: #A7E3CC;
    color: #2D2D2D;
    border: none;
    padding: 10px 28px;
    border-radius: 25px;
    font-size: 15px;
    font-weight: 600;
    font-family: 'Inter', system-ui, sans-serif;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.08),
        0 4px 8px rgba(0, 0, 0, 0.1),
        0 6px 12px rgba(0, 0, 0, 0.06),
        inset 0 -1px 2px rgba(0, 0, 0, 0.1),
        inset 0 1px 1px rgba(255, 255, 255, 0.8),
        inset 0 0 0 1px rgba(45, 45, 45, 0.05);
    width: 100%;
    position: relative;
    z-index: 2;
    overflow: hidden;
    text-shadow: 
        0 0.5px 0.8px rgba(45, 45, 45, 0.07),
        0 0 4px rgba(45, 45, 45, 0.03);
}

/* Paper grain on button */
.orito-icon-cta::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: 
        url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><filter id="btnGrain"><feTurbulence type="fractalNoise" baseFrequency="1.3" numOctaves="3" seed="5" /></filter><rect width="100" height="100" filter="url(%23btnGrain)" opacity="0.3"/></svg>');
    opacity: 0.25;
    mix-blend-mode: overlay;
    pointer-events: none;
    border-radius: inherit;
}

.orito-icon-cta:hover {
    background: #8DD4B8;
    transform: translateY(-2px) rotate(-0.3deg) scale(1.02);
    box-shadow: 
        0 6px 12px rgba(0, 0, 0, 0.12),
        0 10px 20px rgba(0, 0, 0, 0.14),
        0 14px 28px rgba(0, 0, 0, 0.1),
        inset 0 -2px 4px rgba(0, 0, 0, 0.15),
        inset 0 1px 1px rgba(255, 255, 255, 0.9),
        inset 0 0 0 1px rgba(45, 45, 45, 0.08);
}

.orito-icon-cta:active {
    transform: translateY(-1px) rotate(-0.2deg) scale(1.01);
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.1),
        inset 0 2px 4px rgba(0, 0, 0, 0.2),
        inset 0 0 8px rgba(0, 0, 0, 0.1);
}

/* Chat Window Container */
#orito-chat-window {
    position: fixed;
    bottom: 60px;
    right: 30px;
    width: 380px;
    height: 550px;
    background: #FBF6F3;
    border-radius: 20px;
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.14),
        0 12px 32px rgba(0, 0, 0, 0.12);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(45, 45, 45, 0.15);
    font-family: 'Inter', system-ui, sans-serif;
    transform: none;
}

#orito-chat-window.open {
    display: flex;
    animation: slideIn 0.3s ease;
}

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

/* Chat Header */
.orito-chat-header {
    background: #FBF6F3;
    padding: 12px 16px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    border-bottom: 1px solid rgba(45, 45, 45, 0.15);
    position: relative;
}

.orito-header-content {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1;
}

.orito-avatar {
    width: 55px;
    height: 55px;
    border-radius: 0;
    background: transparent;
    padding: 0;
    box-shadow: none;
    flex-shrink: 0;
    border: none;
}

.orito-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.orito-header-text {
    padding-top: 0;
}

.orito-header-text h3 {
    margin: 0;
    font-size: 32px;
    font-weight: 400;
    color: #2D2D2D;
    font-family: 'Playfair Display', Georgia, serif;
    text-shadow: none;
    letter-spacing: 0;
}

.orito-header-text p {
    display: none;
}

.orito-close-btn {
    background: transparent;
    border: none;
    font-size: 32px;
    cursor: pointer;
    color: #2D2D2D;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
    transition: opacity 0.2s ease;
    flex-shrink: 0;
    line-height: 1;
    font-weight: 300;
}

.orito-close-btn:hover {
    opacity: 0.6;
    background: transparent;
}

/* Chat Body - Messages Container */
.orito-chat-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    overflow-x: hidden;
    background: #FBF6F3;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400"><filter id="paperNoise"><feTurbulence type="fractalNoise" baseFrequency="1.1" numOctaves="6" seed="1" stitchTiles="stitch" /><feColorMatrix type="saturate" values="0" /></filter><rect width="400" height="400" filter="url(%23paperNoise)" opacity="0.6"/></svg>');
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: calc(550px - 55px - 48px);
}

.orito-chat-body::-webkit-scrollbar {
    width: 6px;
}

.orito-chat-body::-webkit-scrollbar-track {
    background: transparent;
}

.orito-chat-body::-webkit-scrollbar-thumb {
    background: rgba(45, 45, 45, 0.2);
    border-radius: 3px;
}

/* Message Bubble */
.orito-message {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    animation: messageAppear 0.3s ease;
}

@keyframes messageAppear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.orito-message.bot {
    flex-direction: row;
}

.orito-message.user {
    flex-direction: row-reverse;
}

.orito-message-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #F5E6D3;
    padding: 4px;
    flex-shrink: 0;
    box-shadow: none;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.orito-message-avatar-text {
    display: none;
}

.orito-message-avatar img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.orito-message-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.orito-message.bot .orito-message-bubble {
    background: #F5E6D3;
    color: #2D2D2D;
    border-bottom-left-radius: 4px;
    box-shadow: none;
    border: none;
}

.orito-message.user .orito-message-bubble {
    background: #A7E3CC;
    color: #2D2D2D;
    border-bottom-right-radius: 4px;
}

.orito-message-bubble a {
    color: #2D2D2D;
    font-weight: 600;
    text-decoration: underline;
}

.orito-message-bubble a:hover {
    color: #8DD4B8;
}

/* Typing Indicator */
.orito-typing {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: white;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    max-width: 75px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.orito-typing.active {
    display: flex;
}

.orito-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #A7E3CC;
    animation: typingBounce 1.4s infinite;
}

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

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

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-8px);
    }
}

/* Chat Footer - Input Area */
.orito-chat-footer {
    padding: 10px 16px;
    background: #FBF6F3;
    border-top: 1px solid rgba(45, 45, 45, 0.15);
    display: flex;
    gap: 8px;
    align-items: center;
}

#orito-message-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid rgba(45, 45, 45, 0.2);
    border-radius: 20px;
    font-size: 13px;
    font-family: 'Inter', system-ui, sans-serif;
    outline: none;
    transition: border-color 0.2s ease, background 0.2s ease;
    background: rgba(255, 255, 255, 0.8);
}

#orito-message-input:focus {
    border-color: #A7E3CC;
    background: white;
}

#orito-message-input::placeholder {
    color: #9ca3af;
}

#orito-send-btn {
    background: #A7E3CC;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.1s ease;
    flex-shrink: 0;
}

#orito-send-btn:hover {
    background: #8DD4B8;
    transform: scale(1.05);
}

#orito-send-btn:active {
    transform: scale(0.95);
}

#orito-send-btn:disabled {
    background: #e5e7eb;
    cursor: not-allowed;
    transform: none;
}

#orito-send-btn svg {
    width: 16px;
    height: 16px;
    fill: #2D2D2D;
}

/* Mobile Hide - Desktop Only (hide on <= 900px) */
@media (max-width: 900px) {
    #orito-chat-icon,
    #orito-chat-window {
        display: none !important;
    }
}

/* Accessibility */
.orito-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ============================================
   ENHANCED FEATURES
   ============================================ */

/* Clickable Links */
.orito-message-bubble a,
.orito-link {
    color: #2D2D2D;
    font-weight: 600;
    text-decoration: underline;
    transition: color 0.2s ease;
}

.orito-message-bubble a:hover,
.orito-link:hover {
    color: #8DD4B8;
}

/* Storage Permission Prompt */
.orito-permission-prompt {
    background: white;
    border: 2px solid #A7E3CC;
    border-radius: 12px;
    padding: 16px;
    margin: 12px 0;
    animation: messageAppear 0.3s ease;
}

.orito-permission-content {
    text-align: center;
}

.orito-permission-content p {
    margin: 0;
    color: #2D2D2D;
}

.orito-permission-btn {
    padding: 8px 16px;
    border-radius: 20px;
    border: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Inter', system-ui, sans-serif;
}

.orito-permission-yes {
    background: #A7E3CC;
    color: #2D2D2D;
}

.orito-permission-yes:hover {
    background: #8DD4B8;
    transform: scale(1.05);
}

.orito-permission-no {
    background: #f5f5f5;
    color: #666;
}

.orito-permission-no:hover {
    background: #e5e5e5;
}

/* Chat Options Bar */
.orito-chat-options {
    padding: 8px 20px;
    background: #f5f5f5;
    border-top: 1px solid rgba(45, 45, 45, 0.1);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.orito-option-btn {
    background: transparent;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: all 0.2s ease;
}

.orito-option-btn:hover {
    background: rgba(45, 45, 45, 0.1);
    color: #2D2D2D;
}

/* Markdown Code Styles */
.orito-message-bubble code {
    font-family: 'Courier New', Courier, monospace;
}

.orito-message-bubble pre {
    white-space: pre-wrap;
    word-wrap: break-word;
}

.orito-message-bubble ul,
.orito-message-bubble ol {
    margin: 8px 0;
}

.orito-message-bubble li {
    margin: 4px 0;
}

.orito-message-bubble blockquote {
    font-style: italic;
}

.orito-message-bubble h2,
.orito-message-bubble h3,
.orito-message-bubble h4 {
    font-family: 'Playfair Display', Georgia, serif;
}

/* Enhanced message bubble for better readability */
.orito-message-bubble {
    line-height: 1.6;
}
