/* Avatar Widget CSS - Standalone Styles */

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

/* Prevent text selection on mobile */
.avatar-widget-container {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Allow text selection in messages and input */
.avatar-widget-messages,
.avatar-widget-input {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* Smooth scrolling for iOS */
.avatar-widget-messages {
    -webkit-overflow-scrolling: touch;
}

/* Prevent zoom on iOS when focusing inputs */
input[type="text"],
textarea {
    font-size: 16px;
}

.avatar-widget-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 420px;
    max-width: calc(100vw - 40px);
    height: 650px;
    max-height: calc(100vh - 40px);
    background: rgba(255, 255, 255, 0.98);
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(20px);
}

.avatar-widget-container.top-left {
    top: 20px;
    left: 20px;
    bottom: auto;
    right: auto;
}

.avatar-widget-container.top-right {
    top: 20px;
    right: 20px;
    bottom: auto;
}

.avatar-widget-container.bottom-left {
    bottom: 20px;
    left: 20px;
    right: auto;
}

.avatar-widget-container.minimized {
    height: 70px;
    width: 70px;
    border-radius: 35px;
    cursor: pointer;
    overflow: visible;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

.avatar-widget-header {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
    color: white;
    padding: 18px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.avatar-widget-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { transform: translate(50%, 50%) rotate(0deg); }
    50% { transform: translate(-50%, -50%) rotate(180deg); }
}

.avatar-widget-header h3 {
    margin: 0;
    font-size: 19px;
    font-weight: 600;
    letter-spacing: -0.02em;
    z-index: 1;
    position: relative;
}

.header-controls {
    display: flex;
    gap: 8px;
    z-index: 1;
    position: relative;
}

.avatar-widget-minimize {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    cursor: pointer;
    font-size: 20px;
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.avatar-widget-minimize:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.avatar-widget-minimize:active {
    transform: translateY(0);
}

.avatar-widget-avatar-container {
    height: 260px;
    width: 100%;
    background: linear-gradient(to bottom, #f8f9fa, #e9ecef);
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.avatar-widget-watermark {
    position: absolute;
    bottom: 10px;
    right: 10px;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
    letter-spacing: 0.5px;
    z-index: 1000;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.25);
    padding: 4px 10px;
    border-radius: 12px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.avatar-widget-chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fafbfc;
    overflow: hidden;
    min-height: 0;
}

.avatar-widget-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: #d1d5db #f3f4f6;
    min-height: 0;
}

.avatar-widget-messages::-webkit-scrollbar {
    width: 6px;
}

.avatar-widget-messages::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 3px;
}

.avatar-widget-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
    transition: background 0.3s;
}

.avatar-widget-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

.avatar-widget-message {
    padding: 12px 18px;
    border-radius: 20px;
    max-width: 75%;
    word-wrap: break-word;
    animation: messageSlide 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    font-size: 15px;
    line-height: 1.5;
    letter-spacing: -0.01em;
}

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

.avatar-widget-message.user {
    background: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 6px;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.avatar-widget-message.assistant {
    background: white;
    color: #1f2937;
    align-self: flex-start;
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.06);
}

/* Markdown styles for messages */
.avatar-widget-message strong {
    font-weight: 700;
    color: inherit;
}

.avatar-widget-message em {
    font-style: italic;
    color: inherit;
}

.avatar-widget-message code {
    background: rgba(0, 0, 0, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
}

.avatar-widget-message.user code {
    background: rgba(255, 255, 255, 0.2);
}

/* Code blocks */
.avatar-widget-message pre {
    background: rgba(0, 0, 0, 0.06);
    border-radius: 8px;
    padding: 12px;
    margin: 12px 0;
    overflow-x: auto;
    max-width: 100%;
}

.avatar-widget-message pre code {
    background: transparent;
    padding: 0;
    border-radius: 0;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85em;
    line-height: 1.5;
    display: block;
    white-space: pre;
    color: inherit;
}

.avatar-widget-message.user pre {
    background: rgba(255, 255, 255, 0.15);
}

.avatar-widget-message.user pre code {
    color: white;
}

.avatar-widget-message h1,
.avatar-widget-message h2,
.avatar-widget-message h3,
.avatar-widget-message h4,
.avatar-widget-message h5,
.avatar-widget-message h6 {
    margin: 12px 0 8px 0;
    font-weight: 600;
    line-height: 1.3;
}

.avatar-widget-message h1 { font-size: 1.4em; }
.avatar-widget-message h2 { font-size: 1.3em; }
.avatar-widget-message h3 { font-size: 1.2em; }
.avatar-widget-message h4 { font-size: 1.1em; }
.avatar-widget-message h5 { font-size: 1.05em; }
.avatar-widget-message h6 { font-size: 1em; }

.avatar-widget-message ul,
.avatar-widget-message ol {
    margin: 8px 0;
    padding-left: 24px;
}

.avatar-widget-message li {
    margin: 4px 0;
    line-height: 1.5;
}

.avatar-widget-message ul {
    list-style-type: disc;
}

.avatar-widget-message ol {
    list-style-type: decimal;
}

.avatar-widget-message a {
    color: #6366f1;
    text-decoration: underline;
    transition: color 0.2s;
}

.avatar-widget-message a:hover {
    color: #7c3aed;
}

.avatar-widget-message.user a {
    color: #a5b4fc;
}

.avatar-widget-message.user a:hover {
    color: #c7d2fe;
}

.avatar-widget-message hr {
    margin: 12px 0;
    border: none;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.avatar-widget-message.user hr {
    border-top-color: rgba(255, 255, 255, 0.3);
}

.avatar-widget-audio-message {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 12px 18px;
    border-radius: 20px;
    max-width: 75%;
    animation: messageSlide 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%);
    align-self: flex-end;
    border-bottom-right-radius: 6px;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.avatar-widget-audio-player {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: 12px;
    backdrop-filter: blur(10px);
}

.avatar-widget-play-button {
    width: 32px;
    height: 32px;
    border: none;
    background: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.avatar-widget-play-button:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.avatar-widget-play-button:active {
    transform: scale(0.95);
}

.avatar-widget-audio-duration {
    color: white;
    font-size: 13px;
    font-weight: 500;
    min-width: 45px;
}

.avatar-widget-audio-text {
    color: white;
    font-size: 15px;
    line-height: 1.5;
    letter-spacing: -0.01em;
}

.avatar-widget-audio-visualizer {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 20px;
    margin: 0 8px;
}

.avatar-widget-audio-bar {
    width: 3px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 2px;
    transition: all 0.2s ease;
}

.avatar-widget-audio-bar.active {
    background: white;
    animation: audioBar 0.5s ease-in-out infinite alternate;
}

@keyframes audioBar {
    from { transform: scaleY(0.3); }
    to { transform: scaleY(1); }
}

.avatar-widget-input-container {
    padding: 20px;
    background: white;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    gap: 12px;
    align-items: center;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.avatar-widget-input {
    flex: 1;
    padding: 14px 20px;
    border: 2px solid #e5e7eb;
    border-radius: 16px;
    outline: none;
    font-size: 15px;
    transition: all 0.3s ease;
    background: #f9fafb;
    font-family: inherit;
    letter-spacing: -0.01em;
}

.avatar-widget-input:focus {
    border-color: #6366f1;
    background: white;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.avatar-widget-input::placeholder {
    color: #9ca3af;
}

.avatar-widget-button {
    padding: 12px 12px;
    border: none;
    border-radius: 16px;
    background: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%);
    color: white;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    font-size: 15px;
    font-family: inherit;
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: -0.01em;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
    position: relative;
    overflow: hidden;
}

.avatar-widget-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s;
}

.avatar-widget-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
}

.avatar-widget-button:hover:not(:disabled)::before {
    opacity: 1;
}

.avatar-widget-button:active:not(:disabled) {
    transform: translateY(0);
}

.avatar-widget-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.avatar-widget-button.recording {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
    }
    50% {
        box-shadow: 0 4px 20px rgba(239, 68, 68, 0.45);
    }
}

.avatar-widget-button.icon-button {
    width: 48px;
    height: 48px;
    padding: 12px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    line-height: 1;
    text-align: center;
}

.avatar-widget-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #6b7280;
    font-size: 14px;
    padding: 8px 18px;
    background: white;
    border-radius: 20px;
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.06);
    align-self: flex-start;
    max-width: 75%;
    animation: messageSlide 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.avatar-widget-loading-dots {
    display: flex;
    gap: 4px;
}

.avatar-widget-loading-dots span {
    width: 8px;
    height: 8px;
    background: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%);
    border-radius: 50%;
    animation: loadingDot 1.4s infinite ease-in-out both;
}

.avatar-widget-loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.avatar-widget-loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes loadingDot {
    0%, 80%, 100% {
        transform: scale(0.7);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

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

#avatarCanvas {
    width: 100%;
    height: 100%;
}

.minimized .avatar-widget-header,
.minimized .avatar-widget-chat-container,
.minimized .avatar-widget-avatar-container {
    display: none;
}

.minimized .avatar-widget-watermark {
    display: none;
}

.avatar-widget-minimized-icon {
    display: none;
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    cursor: pointer;
    box-shadow: 0 6px 24px rgba(99, 102, 241, 0.3);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.avatar-widget-minimized-icon::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, transparent 70%);
    animation: shimmer 3s ease-in-out infinite;
}

.avatar-widget-minimized-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.4);
}

.minimized .avatar-widget-minimized-icon {
    display: flex;
}

/* Responsive Design */

/* Tablets - Landscape */
@media (max-width: 1024px) and (min-width: 769px) {
    .avatar-widget-container {
        width: 380px;
        height: 600px;
    }
    
    .avatar-widget-avatar-container {
        height: 280px;
    }
    
    .avatar-widget-chat-container {
        flex: 1;
        min-height: 0;
    }
}

/* Tablets - Portrait */
@media (max-width: 768px) and (min-width: 481px) {
    .avatar-widget-container {
        width: 360px;
        height: 580px;
        bottom: 15px;
        right: 15px;
    }
    
    .avatar-widget-container.top-left,
    .avatar-widget-container.top-right {
        top: 15px;
    }
    
    .avatar-widget-container.bottom-left {
        bottom: 15px;
        left: 15px;
    }
    
    .avatar-widget-header {
        padding: 16px 20px;
    }
    
    .avatar-widget-header h3 {
        font-size: 17px;
    }
    
    .avatar-widget-minimize {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }
    
    .avatar-widget-avatar-container {
        height: 260px;
        flex-shrink: 0;
    }
    
    .avatar-widget-chat-container {
        flex: 1;
        min-height: 0;
    }
    
    .avatar-widget-messages {
        padding: 16px;
        gap: 10px;
    }
    
    .avatar-widget-message {
        padding: 10px 16px;
        font-size: 14px;
    }
    
    .avatar-widget-input-container {
        padding: 16px;
        gap: 10px;
        flex-shrink: 0;
    }
    
    .avatar-widget-input {
        padding: 12px 16px;
        font-size: 14px;
    }
    
    .avatar-widget-button {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .avatar-widget-button.icon-button {
        width: 42px;
        height: 42px;
        font-size: 18px;
        line-height: 1;
        padding:12px 24px;
        text-align: center;
    }
}

/* Mobile - Large (iPhone Plus, Android large) */
@media (max-width: 480px) and (min-width: 376px) {
    .avatar-widget-container {
        position: fixed;
        width: calc(100vw - 20px);
        height: calc(100vh - 20px);
        max-height: 700px;
        bottom: 10px;
        right: 10px;
        left: 10px;
        margin: 0 auto;
    }
    
    .avatar-widget-container.top-left,
    .avatar-widget-container.top-right,
    .avatar-widget-container.bottom-left {
        top: auto;
        bottom: 10px;
        left: 10px;
        right: 10px;
    }
    
    .avatar-widget-header {
        padding: 14px 18px;
        flex-shrink: 0;
    }
    
    .avatar-widget-header h3 {
        font-size: 16px;
    }
    
    .avatar-widget-minimize {
        width: 30px;
        height: 30px;
        font-size: 16px;
        border-radius: 10px;
    }
    
    .avatar-widget-avatar-container {
        height: 35vh;
        min-height: 200px;
        max-height: 280px;
        flex-shrink: 0;
    }
    
    .avatar-widget-chat-container {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    
    .avatar-widget-messages {
        flex: 1;
        padding: 14px;
        gap: 10px;
        min-height: 0;
        overflow-y: auto;
    }
    
    .avatar-widget-message,
    .avatar-widget-audio-message {
        max-width: 85%;
        padding: 10px 14px;
        font-size: 14px;
        border-radius: 18px;
    }
    
    .avatar-widget-message.user {
        border-bottom-right-radius: 4px;
    }
    
    .avatar-widget-message.assistant {
        border-bottom-left-radius: 4px;
    }
    
    .avatar-widget-input-container {
        padding: 12px;
        gap: 8px;
        flex-wrap: nowrap;
        flex-shrink: 0;
    }
    
    .avatar-widget-input {
        padding: 12px 14px;
        font-size: 14px;
        border-radius: 14px;
        min-width: 0;
        flex: 1;
    }
    
    .avatar-widget-button {
        padding: 10px 16px;
        font-size: 13px;
        border-radius: 14px;
        white-space: nowrap;
    }
    
    .avatar-widget-button.icon-button {
        width: 40px;
        height: 40px;
        font-size: 16px;
        flex-shrink: 0;
        line-height: 1;
        text-align: center;
    }
    
    .avatar-widget-loading {
        font-size: 13px;
        padding: 8px 14px;
    }
    
    .avatar-widget-loading-dots span {
        width: 6px;
        height: 6px;
    }
}

/* Mobile - Standard (iPhone, Android standard) */
@media (max-width: 375px) {
    .avatar-widget-container {
        position: fixed;
        width: 100vw;
        height: 100vh;
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        border-radius: 0;
        max-height: none;
    }
    
    .avatar-widget-container.minimized {
        width: 60px;
        height: 60px;
        border-radius: 30px;
        bottom: 20px;
        right: 20px;
        left: auto;
        top: auto;
    }
    
    .avatar-widget-minimized-icon {
        width: 60px;
        height: 60px;
        font-size: 28px;
    }
    
    .avatar-widget-container.top-left,
    .avatar-widget-container.top-right,
    .avatar-widget-container.bottom-left {
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
    }
    
    .avatar-widget-header {
        padding: 12px 16px;
        border-radius: 0;
        flex-shrink: 0;
    }
    
    .avatar-widget-header h3 {
        font-size: 15px;
    }
    
    .header-controls {
        gap: 6px;
    }
    
    .avatar-widget-minimize {
        width: 28px;
        height: 28px;
        font-size: 16px;
        border-radius: 8px;
    }
    
    .avatar-widget-avatar-container {
        height: 30vh;
        min-height: 180px;
        max-height: 250px;
        flex-shrink: 0;
    }
    
    .avatar-widget-chat-container {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    
    .avatar-widget-messages {
        flex: 1;
        padding: 12px;
        gap: 8px;
        min-height: 0;
        overflow-y: auto;
    }
    
    .avatar-widget-message,
    .avatar-widget-audio-message {
        max-width: 90%;
        padding: 9px 13px;
        font-size: 13px;
        border-radius: 16px;
        line-height: 1.4;
    }
    
    .avatar-widget-audio-player {
        padding: 6px 12px;
        gap: 8px;
    }
    
    .avatar-widget-play-button {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
    
    .avatar-widget-audio-duration {
        font-size: 12px;
        min-width: 35px;
    }
    
    .avatar-widget-audio-visualizer {
        gap: 1px;
        height: 16px;
        margin: 0 6px;
    }
    
    .avatar-widget-audio-bar {
        width: 2px;
    }
    
    .avatar-widget-input-container {
        padding: 10px;
        gap: 6px;
        background: #ffffff;
        border-top: 1px solid rgba(0, 0, 0, 0.08);
        flex-shrink: 0;
    }
    
    .avatar-widget-input {
        padding: 10px 12px;
        font-size: 13px;
        border-radius: 12px;
        border-width: 1.5px;
    }
    
    .avatar-widget-button {
        padding: 10px 14px;
        font-size: 12px;
        border-radius: 12px;
        font-weight: 500;
    }
    
    .avatar-widget-button.icon-button {
        width: 36px;
        height: 36px;
        font-size: 16px;
        line-height: 1;
        text-align: center;
    }
    
    .avatar-widget-loading {
        font-size: 12px;
        padding: 6px 12px;
    }
    
    .avatar-widget-loading-dots span {
        width: 5px;
        height: 5px;
    }
}

/* Landscape Mode - Mobile */
@media (max-width: 896px) and (max-height: 414px) and (orientation: landscape) {
    .avatar-widget-container {
        width: 50vw;
        max-width: 420px;
        height: calc(100vh - 20px);
        right: 10px;
        bottom: 10px;
    }
    
    .avatar-widget-avatar-container {
        height: 35%;
        min-height: 120px;
        flex-shrink: 0;
    }
    
    .avatar-widget-chat-container {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    
    .avatar-widget-messages {
        flex: 1;
        padding: 10px;
        min-height: 0;
        overflow-y: auto;
    }
    
    .avatar-widget-message {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .avatar-widget-input-container {
        padding: 10px;
        flex-shrink: 0;
    }
    
    .avatar-widget-input {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .avatar-widget-button {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .avatar-widget-button.icon-button {
        width: 34px;
        height: 34px;
        font-size: 14px;
        line-height: 1;
        text-align: center;
    }
}

/* Very Small Devices */
@media (max-width: 320px) {
    .avatar-widget-container {
        font-size: 12px;
    }
    
    .avatar-widget-header h3 {
        font-size: 14px;
    }
    
    .avatar-widget-minimize {
        width: 26px;
        height: 26px;
        font-size: 14px;
    }
    
    .avatar-widget-message {
        font-size: 12px;
        padding: 8px 11px;
    }
    
    .avatar-widget-input {
        font-size: 12px;
        padding: 9px 11px;
    }
    
    .avatar-widget-button {
        font-size: 11px;
        padding: 9px 12px;
    }
    
    .avatar-widget-button.icon-button {
        width: 32px;
        height: 32px;
        font-size: 14px;
        line-height: 1;
        text-align: center;
    }
}

/* Touch-friendly adjustments for all touch devices */
@media (hover: none) and (pointer: coarse) {
    .avatar-widget-minimize,
    .avatar-widget-button,
    .avatar-widget-play-button {
        min-width: 44px;
        min-height: 44px;
    }
    
    .avatar-widget-input {
        min-height: 44px;
    }
    
    /* Prevent iOS zoom on input focus */
    .avatar-widget-input {
        font-size: 16px;
    }
    
    @media (max-width: 480px) {
        .avatar-widget-input {
            font-size: 16px;
        }
    }
}

/* Privacy Consent Styles */
.avatar-widget-privacy-consent {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 20px;
    background: #fafbfc;
    overflow: hidden;
}

.avatar-widget-privacy-content {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.06);
    text-align: center;
    width: 100%;
    height: 100%;
    max-height: calc(100vh - 200px);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #d1d5db #f3f4f6;
}

.avatar-widget-privacy-content h4 {
    color: #1f2937;
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 16px 0;
    letter-spacing: -0.02em;
}

.avatar-widget-privacy-content::-webkit-scrollbar {
    width: 6px;
}

.avatar-widget-privacy-content::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 3px;
}

.avatar-widget-privacy-content::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
    transition: background 0.3s;
}

.avatar-widget-privacy-content::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

.avatar-widget-privacy-text {
    /* margin-bottom: 20px; */
    text-align: left;
}

.avatar-widget-privacy-text p {
    color: #4b5563;
    font-size: 14px;
    line-height: 1.6;
    margin: 0 0 16px 0;
    letter-spacing: -0.01em;
}

.avatar-widget-privacy-text p:last-child {
    margin-bottom: 0;
}

.avatar-widget-privacy-text strong {
    color: #1f2937;
    font-weight: 600;
}

.avatar-widget-checkbox-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    /* margin: 16px 0; */
    cursor: pointer;
    font-size: 14px;
    color: #374151;
    line-height: 1.5;
}

.avatar-widget-checkbox-container input[type="checkbox"] {
    width: 18px;
    height: 18px;
    border: 2px solid #d1d5db;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    position: relative;
    margin: 0;
    flex-shrink: 0;
    accent-color: #6366f1;
}

.avatar-widget-checkbox-container input[type="checkbox"]:checked {
    background: #6366f1;
    border-color: #6366f1;
}

.avatar-widget-checkbox-text {
    flex: 1;
    text-align: left;
}

.avatar-widget-checkbox-text a {
    color: #6366f1;
    text-decoration: none;
    font-weight: 500;
}

.avatar-widget-checkbox-text a:hover {
    text-decoration: underline;
}

.avatar-widget-accept-button {
    margin-top: 8px;
    min-width: 200px;
    padding: 14px 24px !important;
}

.avatar-widget-accept-button:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15) !important;
}

/* Mobile adjustments for privacy consent */
@media (max-width: 768px) {
    .avatar-widget-privacy-content {
        /* padding: 24px 20px; */
        border-radius: 16px;
    }
    
    .avatar-widget-privacy-content h4 {
        font-size: 18px;
        margin-bottom: 12px;
    }
    
    .avatar-widget-privacy-content p {
        font-size: 14px;
        margin-bottom: 16px;
    }
    
    .avatar-widget-checkbox-container {
        font-size: 13px;
        /* margin: 16px 0; */
        text-align: left;
    }
    
    .avatar-widget-accept-button {
        min-width: auto;
        width: 100%;
        padding: 12px 20px !important;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .avatar-widget-privacy-consent {
        padding: 16px;
    }
    
    .avatar-widget-privacy-content {
        padding: 20px 16px;
        border-radius: 14px;
    }
    
    .avatar-widget-privacy-content h4 {
        font-size: 16px;
    }
    
    .avatar-widget-privacy-content p {
        font-size: 13px;
        line-height: 1.5;
    }
    
    .avatar-widget-checkbox-container {
        font-size: 12px;
        gap: 8px;
        margin: 14px 0;
    }
    
    .avatar-widget-checkbox-container input[type="checkbox"] {
        width: 16px;
        height: 16px;
    }
}

/* Audio transcription styles */
.avatar-widget-audio-transcription {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 14px;
    line-height: 1.5;
    color: #555;
    animation: fadeIn 0.3s ease-in;
}

.avatar-widget-audio-transcription .transcription-label {
    font-weight: 600;
    color: #333;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.7;
    display: block;
    margin-bottom: 4px;
}

/* Streaming message styles */
.avatar-widget-message.streaming {
    position: relative;
}

.avatar-widget-message.streaming .streaming-cursor {
    animation: blink 1s infinite;
    font-weight: bold;
    color: #2563eb;
    margin-left: 2px;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.avatar-widget-message.streaming .streaming-content {
    display: inline;
}

/* Smooth streaming animation */
.avatar-widget-message.streaming {
    animation: fadeIn 0.3s ease-in;
}

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

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .avatar-widget-container {
        border-width: 0.5px;
    }
    
    .avatar-widget-message {
        border-width: 0.5px;
    }
}