* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-blue: #1e3a8a;
    --secondary-blue: #3b82f6;
    --light-blue: #dbeafe;
    --dark-blue: #1e40af;
    --text-dark: #1f2937;
    --text-light: #6b7280;
    --background: #f3f4f6;
    --white: #ffffff;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--background);
    color: var(--text-dark);
    overflow: hidden;
    height: 100vh;
}

/* Custom Scrollbar Styles */
.quick-buttons-scrollable::-webkit-scrollbar,
.chat-history::-webkit-scrollbar {
    width: 8px;
}

.quick-buttons-scrollable::-webkit-scrollbar-track,
.chat-history::-webkit-scrollbar-track {
    background: rgba(30, 58, 138, 0.05);
    border-radius: 4px;
}

.quick-buttons-scrollable::-webkit-scrollbar-thumb,
.chat-history::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--secondary-blue), var(--dark-blue));
    border-radius: 4px;
    transition: background 0.3s;
}

.quick-buttons-scrollable::-webkit-scrollbar-thumb:hover,
.chat-history::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--primary-blue), var(--secondary-blue));
}

/* For Firefox */
.quick-buttons-scrollable,
.chat-history {
    scrollbar-width: thin;
    scrollbar-color: var(--secondary-blue) rgba(30, 58, 138, 0.05);
}

.container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

.left-panel {
    flex: 1.2;
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--dark-blue) 100%);
    padding: clamp(1rem, 3vw, 2rem);
    display: flex;
    flex-direction: column;
    color: var(--white);
}

.right-panel {
    flex: 1;
    background: var(--white);
    display: flex;
    flex-direction: column;
    border-left: 3px solid var(--secondary-blue);
}

.avatar-header h1 {
    font-size: clamp(1.25rem, 4vw, 2rem);
    margin-bottom: clamp(0.5rem, 2vh, 1rem);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.app-logo {
    width: clamp(140px, 25vw, 220px);
    height: auto;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: clamp(0.25rem, 0.5vh, 0.4rem);
    display: block;
    filter: drop-shadow(2px 2px 6px rgba(0, 0, 0, 0.4));
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: clamp(0.3rem, 1vw, 0.5rem);
    margin-bottom: clamp(1rem, 2vh, 1.5rem);
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
}

.status-dot {
    width: clamp(10px, 2vw, 12px);
    height: clamp(10px, 2vw, 12px);
    border-radius: 50%;
    background: var(--success);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.video-container {
    position: relative;
    width: 95%;
    margin-left: auto;
    margin-right: auto;
    aspect-ratio: 9/16;
    background: #f4f4f5;
    border-radius: clamp(0.5rem, 2vw, 1rem);
    overflow: hidden;
    margin-bottom: clamp(1rem, 2vh, 1.5rem);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    max-height: 55vh;
}

.avatar-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: opacity 0.3s ease-in-out;
}

.video-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(244, 244, 245, 0.95);
    z-index: 10;
    backdrop-filter: blur(5px);
}

.loader-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(96, 165, 250, 0.2);
    border-top-color: #60a5fa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loader-text {
    margin-top: 1rem;
    color: #60a5fa;
    font-size: 1rem;
    font-weight: 500;
}

.video-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(30, 58, 138, 0.8);
    color: var(--white);
}

.placeholder-icon {
    font-size: 5rem;
    margin-bottom: 1rem;
}

.video-placeholder p {
    font-size: 1.5rem;
}

.current-answer {
    background: rgba(255, 255, 255, 0.1);
    padding: clamp(1rem, 2.5vw, 1.5rem);
    border-radius: clamp(0.5rem, 1.5vw, 0.75rem);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.answer-text {
    font-size: clamp(1rem, 3vw, 1.3rem);
    line-height: 1.6;
}

.chat-section {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: clamp(1rem, 2.5vw, 1.5rem);
    background: var(--primary-blue);
    color: var(--white);
}

.chat-header h2 {
    font-size: clamp(1.1rem, 3.5vw, 1.5rem);
}

.clear-btn {
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: clamp(0.4rem, 1.2vw, 0.5rem) clamp(0.75rem, 2vw, 1rem);
    border-radius: clamp(0.4rem, 1vw, 0.5rem);
    cursor: pointer;
    font-size: clamp(0.85rem, 2.2vw, 1rem);
    transition: background 0.3s;
}

.clear-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.admin-link {
    display: flex;
    align-items: center;
    gap: clamp(0.5rem, 1.5vw, 0.75rem);
    padding: clamp(0.75rem, 2vw, 1rem) clamp(1rem, 3vw, 1.5rem);
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: white;
    text-decoration: none;
    border-radius: 0;
    transition: all 0.3s ease;
    border-bottom: 3px solid rgba(124, 58, 237, 0.3);
    font-weight: 600;
    font-size: clamp(0.95rem, 2.5vw, 1.1rem);
}

.admin-link:hover {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    border-bottom-color: rgba(109, 40, 217, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.admin-link:active {
    transform: translateY(0);
}

.admin-icon {
    width: clamp(20px, 4vw, 28px);
    height: clamp(20px, 4vw, 28px);
    flex-shrink: 0;
    stroke-width: 2;
    animation: rotate 8s linear infinite;
    display: block;
}

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

.admin-link:hover .admin-icon {
    animation: rotate 2s linear infinite;
}

.admin-text {
    letter-spacing: 0.5px;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: clamp(1rem, 2.5vw, 1.5rem);
    background: var(--light-blue);
}

.chat-message {
    margin-bottom: clamp(0.75rem, 2vw, 1rem);
    animation: slideIn 0.3s ease-out;
}

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

.message-question {
    background: var(--white);
    padding: clamp(0.75rem, 2vw, 1rem);
    border-radius: clamp(0.5rem, 1.5vw, 0.75rem);
    margin-bottom: clamp(0.4rem, 1vw, 0.5rem);
    border-left: clamp(3px, 0.8vw, 4px) solid var(--secondary-blue);
    font-size: clamp(0.95rem, 2.5vw, 1.1rem);
}

.message-answer {
    background: var(--secondary-blue);
    color: var(--white);
    padding: clamp(0.75rem, 2vw, 1rem);
    border-radius: clamp(0.5rem, 1.5vw, 0.75rem);
    font-size: clamp(0.95rem, 2.5vw, 1.1rem);
}

.message-source {
    font-size: clamp(0.8rem, 2vw, 0.9rem);
    opacity: 0.8;
    margin-top: clamp(0.4rem, 1vw, 0.5rem);
}

.quick-buttons {
    background: var(--background);
}

.quick-buttons-scrollable {
    padding: clamp(1rem, 2.5vw, 1.5rem);
    max-height: 40vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.quick-buttons-scrollable h3 {
    font-size: clamp(1rem, 2.8vw, 1.2rem);
    margin-bottom: clamp(0.75rem, 2vw, 1rem);
    color: var(--primary-blue);
    position: sticky;
    top: 0;
    background: var(--background);
    z-index: 1;
    padding-bottom: clamp(0.5rem, 1.5vw, 0.75rem);
    margin-top: 0;
}

.button-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: clamp(0.5rem, 1.5vw, 0.75rem);
    padding-bottom: clamp(0.5rem, 1.5vw, 0.75rem);
}

.quick-btn {
    background: var(--white);
    color: var(--primary-blue);
    border: 2px solid var(--secondary-blue);
    padding: clamp(0.75rem, 2vw, 1rem);
    border-radius: clamp(0.4rem, 1vw, 0.5rem);
    cursor: pointer;
    font-size: clamp(0.85rem, 2.2vw, 1rem);
    font-weight: 600;
    transition: all 0.3s;
}

.quick-btn:hover {
    background: var(--secondary-blue);
    color: var(--white);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.input-section {
    padding: clamp(1rem, 2.5vw, 1.5rem);
    background: var(--white);
    border-top: 2px solid var(--light-blue);
}

.question-form {
    display: flex;
    gap: clamp(0.5rem, 2vw, 1rem);
}

.question-input {
    flex: 1;
    padding: clamp(0.75rem, 2vw, 1rem);
    font-size: clamp(0.95rem, 2.5vw, 1.1rem);
    border: 2px solid var(--secondary-blue);
    border-radius: clamp(0.4rem, 1vw, 0.5rem);
    outline: none;
    transition: border-color 0.3s;
}

.question-input:focus {
    border-color: var(--primary-blue);
}

.submit-btn {
    background: var(--secondary-blue);
    color: var(--white);
    border: none;
    padding: clamp(0.75rem, 2vw, 1rem) clamp(1.5rem, 4vw, 2rem);
    border-radius: clamp(0.4rem, 1vw, 0.5rem);
    cursor: pointer;
    font-size: clamp(0.95rem, 2.5vw, 1.1rem);
    font-weight: 600;
    transition: background 0.3s;
}

.submit-btn:hover {
    background: var(--primary-blue);
}

.submit-btn:disabled {
    background: var(--text-light);
    cursor: not-allowed;
}

/* Menu Toggle Button */
.menu-toggle {
    position: fixed;
    z-index: 1001;
    background: linear-gradient(135deg, var(--primary-blue), var(--secondary-blue));
    border: clamp(1px, 0.2vw, 2px) solid rgba(255, 255, 255, 0.2);
    border-radius: clamp(0.5rem, 1.5vw, 0.75rem);
    padding: clamp(0.5rem, 1.5vw, 0.75rem) clamp(0.75rem, 2.5vw, 1.25rem);
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: clamp(0.5rem, 1.5vw, 0.75rem);
    backdrop-filter: blur(10px);
}

.menu-toggle:hover {
    background: linear-gradient(135deg, var(--secondary-blue), var(--primary-blue));
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    transform: translateY(-2px);
}

.menu-toggle:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.menu-icon {
    width: clamp(20px, 5vw, 24px);
    height: clamp(2px, 0.4vw, 2px);
    background: white;
    position: relative;
    display: block;
    border-radius: 2px;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.menu-icon::before,
.menu-icon::after {
    content: '';
    position: absolute;
    width: clamp(20px, 5vw, 24px);
    height: clamp(2px, 0.4vw, 2px);
    background: white;
    border-radius: 2px;
    transition: all 0.3s ease;
    left: 0;
}

.menu-icon::before {
    top: clamp(-7px, -1.5vw, -6px);
}

.menu-icon::after {
    top: clamp(6px, 1.5vw, 7px);
}

.menu-toggle.active .menu-icon {
    background: transparent;
}

.menu-toggle.active .menu-icon::before {
    top: 0;
    transform: rotate(45deg);
}

.menu-toggle.active .menu-icon::after {
    top: 0;
    transform: rotate(-45deg);
}

.menu-toggle.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.menu-label {
    color: white;
    font-size: clamp(0.875rem, 2vw, 1rem);
    font-weight: 600;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

/* Menu Overlay */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Landscape Orientation (Horizontal) - Menu from Right */
@media (orientation: landscape) {
    .menu-toggle {
        top: clamp(15px, 2vh, 20px);
        right: clamp(15px, 2vw, 20px);
    }
    
    .menu-panel {
        position: fixed;
        right: 0;
        top: 0;
        height: 100vh;
        width: 450px;
        max-width: 90vw;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1000;
        box-shadow: -4px 0 12px rgba(0, 0, 0, 0.2);
    }
    
    .menu-panel.active {
        transform: translateX(0);
    }
    
    .container {
        height: 100vh;
    }
    
    .left-panel {
        flex: 1;
        width: 100%;
    }
}

/* Portrait Orientation (Vertical) - Menu from Bottom */
@media (orientation: portrait) {
    .menu-toggle {
        bottom: clamp(20px, 3vh, 30px);
        right: 50%;
        transform: translateX(50%);
        padding: clamp(0.875rem, 2.8vw, 1.125rem) clamp(1.5rem, 4.5vw, 2rem);
        border-radius: clamp(1.25rem, 3.5vw, 1.75rem);
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 
                    0 0 0 1px rgba(255, 255, 255, 0.15),
                    inset 0 1px 0 rgba(255, 255, 255, 0.2);
        background: linear-gradient(135deg, #1e40af 0%, #3b82f6 50%, #06b6d4 100%);
        backdrop-filter: blur(12px);
    }
    
    .menu-toggle.active {
        transform: translateX(50%) scale(1);
        background: linear-gradient(135deg, #06b6d4 0%, #3b82f6 50%, #1e40af 100%);
    }
    
    .menu-toggle:hover {
        transform: translateX(50%) scale(1.05);
    }
    
    .menu-toggle:active {
        transform: translateX(50%) scale(0.95);
    }
    
    .menu-icon {
        width: clamp(26px, 6.5vw, 30px);
        height: clamp(3px, 0.7vw, 3.5px);
    }
    
    .menu-icon::before {
        top: clamp(-10px, -2.5vw, -9px);
        width: clamp(26px, 6.5vw, 30px);
        height: clamp(3px, 0.7vw, 3.5px);
        left: 0;
    }
    
    .menu-icon::after {
        top: clamp(10px, 2.5vw, 9px);
        width: clamp(26px, 6.5vw, 30px);
        height: clamp(3px, 0.7vw, 3.5px);
        left: 0;
    }
    
    .menu-toggle.active .menu-icon {
        background: transparent;
    }
    
    .menu-toggle.active .menu-icon::before {
        top: 0;
        transform: rotate(45deg);
        width: clamp(26px, 6.5vw, 30px);
    }
    
    .menu-toggle.active .menu-icon::after {
        top: 0;
        transform: rotate(-45deg);
        width: clamp(26px, 6.5vw, 30px);
    }
    
    .menu-label {
        font-size: clamp(1.05rem, 3vw, 1.2rem);
        font-weight: 700;
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
        letter-spacing: 0.8px;
    }
    
    .current-answer {
        padding-bottom: clamp(100px, 15vh, 140px);
    }
    
    .container {
        flex-direction: column;
        height: 100vh;
    }
    
    .left-panel {
        flex: 1;
        width: 100%;
    }
    
    .menu-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 70vh;
        width: 100%;
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1000;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.2);
        border-radius: 20px 20px 0 0;
    }
    
    .menu-panel.active {
        transform: translateY(0);
    }
}

@media (max-width: 1024px) {
    .button-grid {
        grid-template-columns: 1fr;
    }
}

/* Small Mobile Devices */
@media (max-width: 480px) {
    .avatar-header h1 {
        font-size: clamp(1.1rem, 5vw, 1.5rem);
    }
    
    .app-logo {
        width: clamp(110px, 30vw, 160px);
    }
    
    .status-indicator {
        font-size: clamp(0.85rem, 3vw, 1rem);
    }
    
    .question-form {
        flex-direction: column;
    }
    
    .submit-btn {
        width: 100%;
        padding: clamp(0.85rem, 3vw, 1rem);
    }
    
    .chat-header h2 {
        font-size: clamp(1rem, 4vw, 1.2rem);
    }
    
    .quick-btn {
        font-size: clamp(0.9rem, 3vw, 1rem);
        padding: clamp(0.85rem, 3vw, 1rem);
    }
}

/* Very Small Mobile Devices */
@media (max-width: 360px) {
    .left-panel {
        padding: clamp(0.75rem, 4vw, 1rem);
    }
    
    .chat-header {
        padding: clamp(0.75rem, 3vw, 1rem);
    }
    
    .avatar-header h1 {
        font-size: clamp(1rem, 6vw, 1.3rem);
    }
    
    .app-logo {
        width: clamp(100px, 35vw, 150px);
    }
}

.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Voice Input Overlay */
.voice-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.voice-indicator {
    text-align: center;
    padding: clamp(1.5rem, 4vw, 2rem);
    max-width: clamp(300px, 80vw, 500px);
    width: 90%;
}

.voice-wave {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(6px, 1.5vw, 8px);
    margin-bottom: clamp(20px, 4vh, 30px);
    height: clamp(60px, 12vh, 80px);
}

.wave-bar {
    width: clamp(8px, 2vw, 12px);
    height: 100%;
    background: linear-gradient(180deg, #06b6d4, #0ea5e9);
    border-radius: 10px;
    animation: wave 1.2s ease-in-out infinite;
}

.wave-bar:nth-child(1) {
    animation-delay: 0s;
}

.wave-bar:nth-child(2) {
    animation-delay: 0.1s;
}

.wave-bar:nth-child(3) {
    animation-delay: 0.2s;
}

.wave-bar:nth-child(4) {
    animation-delay: 0.3s;
}

.wave-bar:nth-child(5) {
    animation-delay: 0.4s;
}

@keyframes wave {
    0%, 100% {
        transform: scaleY(0.3);
        opacity: 0.7;
    }
    50% {
        transform: scaleY(1);
        opacity: 1;
    }
}

.voice-status {
    font-size: clamp(24px, 5vw, 32px);
    color: #ffffff;
    font-weight: 600;
    margin-bottom: clamp(15px, 3vh, 20px);
}

.voice-transcript {
    font-size: clamp(18px, 3.5vw, 24px);
    color: #06b6d4;
    font-weight: 500;
    min-height: clamp(30px, 6vh, 40px);
    margin-bottom: clamp(20px, 4vh, 30px);
    padding: clamp(10px, 2vh, 15px);
    background: rgba(6, 182, 212, 0.1);
    border-radius: 12px;
    border: 2px solid rgba(6, 182, 212, 0.3);
}

.voice-cancel-btn {
    background: linear-gradient(135deg, #dc2626, #991b1b);
    color: white;
    border: none;
    padding: clamp(12px, 2.5vh, 16px) clamp(30px, 6vw, 40px);
    font-size: clamp(16px, 3vw, 20px);
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.voice-cancel-btn:hover {
    background: linear-gradient(135deg, #b91c1c, #7f1d1d);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(220, 38, 38, 0.4);
}

.voice-cancel-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
}
