@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+JP:wght@100;200;300;400;500;600;700&display=swap');

body {
    font-family: "IBM Plex Sans JP", sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    height: -webkit-fill-available;
    min-height: -webkit-fill-available;
    background-color: #e47b02;
    /* Light blue background for the entire screen */
    transition: background-color 0.3s ease;
}

html {
    height: -webkit-fill-available;
}

/* Green gradient background when listening */
body.listening {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}

.chat-container {
    width: 100%;
    max-width: 600px;
    height: 80vh;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    /* Gradient background */
    border-radius: 5px;
    /* More rounded corners */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    /* Soft shadow */
    display: flex;
    flex-direction: column;
    position: relative;
    padding-bottom: 145px;
    border: none;
    backdrop-filter: blur(10px);
    /* Glass effect */
    transition: height 0.3s ease, max-width 0.3s ease;
}

/* User info bar */
.user-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #e47b02;
    color: white;
    border-radius: 20px 20px 0 0;
    font-size: 11px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.user-welcome {
    font-weight: 500;
}

.logout-link {
    color: white;
    text-decoration: none;
    padding: 5px 10px;
    border-radius: 15px;
    transition: background-color 0.3s ease;
}

.logout-link:hover {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    text-decoration: none;
}

/* Removed expanded chat container when listening to prevent size changes */
/* body.listening .chat-container {
    height: 85vh;
    max-width: 650px;
} */

.chat-box {
    flex: 1;
    /*padding: 20px; */
    overflow-y: auto;
    border-bottom: none;
    /* Remove border */
    display: flex;
    flex-direction: column;
    scrollbar-width: thin;
    scrollbar-color: #ddd transparent;
}

/* Custom scrollbar for webkit browsers */
.chat-box::-webkit-scrollbar {
    width: 6px;
}

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

.chat-box::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

.input-container {
    position: absolute;
    bottom: 10px;
    left: 10px;
    right: 10px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    border-radius: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

#user-input {
    flex: 1;
    margin: 0 10px 0 0;
    padding: 15px 20px;
    border: none;
    border-radius: 1px;
    resize: none;
    background: rgba(228, 228, 228, 0.8);
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
}

#user-input:focus {
    background: rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 0 2px rgba(41, 166, 255, 0.3);
}

#send-button {
    width: 50px;
    height: 50px;
    margin: 0;
    padding: 0;
    background: #e47b02;
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(41, 166, 255, 0.3);
}

#send-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(41, 166, 255, 0.4);
    background: #e47b02;
}

#send-button:active {
    transform: translateY(0);
}

#voice-button {
    width: 60px;
    height: 60px;
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
}

#voice-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4);
    background: linear-gradient(135deg, #20c997 0%, #e47b02 100%);
}

#voice-button.recording {
    background: linear-gradient(135deg, #dc3545 0%, #e74c3c 100%);
    animation: pulse 1s infinite;
}

#voice-button.listening {
    background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%);
    animation: listeningPulse 2s infinite;
}

#typing-button {
    width: 60px;
    height: 60px;
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.3);
}

#typing-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 117, 125, 0.4);
    background: linear-gradient(135deg, #495057 0%, #343a40 100%);
}

#voice-button.continuous {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
    animation: continuousPulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(220, 53, 69, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0);
    }
}

@keyframes listeningPulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.7);
        transform: scale(1);
    }

    50% {
        box-shadow: 0 0 0 20px rgba(255, 193, 7, 0);
        transform: scale(1.05);
    }
}

.user-message {
    background: #e47b02;
    color: #fff;
    padding: 15px 20px;
    border-radius: 20px 20px 5px 20px;
    max-width: 70%;
    margin: 8px 0;
    align-self: flex-end;
    box-shadow: 0 3px 10px rgba(41, 166, 255, 0.3);
    animation: slideInRight 0.3s ease;
    position: relative;
}

.ai-message {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    color: #333;
    padding: 15px 20px;
    border-radius: 20px 20px 20px 5px;
    max-width: 70%;
    margin: 8px 0;
    align-self: flex-start;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.05);
    animation: slideInLeft 0.3s ease;
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 5px;
    text-align: right;
    font-weight: 300;
}

.user-message .message-time {
    color: rgba(255, 255, 255, 0.8);
}

.ai-message .message-time {
    color: rgba(0, 0, 0, 0.5);
}

/* Message animations */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Error message styling */
.error-message {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
    color: #fff;
    padding: 15px 20px;
    border-radius: 20px;
    max-width: 70%;
    margin: 8px auto;
    text-align: center;
    box-shadow: 0 3px 10px rgba(255, 107, 107, 0.3);
    animation: slideInLeft 0.3s ease;
}

/* Responsive design */
@media (max-width: 480px) {
    .chat-container {
        height: 95vh !important;
        margin: 10px;
        border-radius: 1px;
    }

    .user-message,
    .ai-message {
        max-width: 85%;
        padding: 12px 16px;
    }

    #user-input {
        font-size: 14px;
        /* Prevent zoom on iOS */
    }
}

/* System messages for email notifications */
.system-message {
    text-align: center;
    padding: 8px 12px;
    margin: 8px auto;
    border-radius: 15px;
    font-size: 14px;
    font-weight: 500;
    max-width: 80%;
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
    border: 1px solid #ced4da;
    color: #495057;
    animation: slideIn 0.3s ease;
}

.system-message.success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border-color: #c3e6cb;
    color: #155724;
}

.system-message.error {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    border-color: #f5c6cb;
    color: #721c24;
}

.system-message.info {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    border-color: #bee5eb;
    color: #0c5460;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

button#switch-mode-button {
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    background: none;
    border: none;
    color: #28a0f6;
}

.logs-container {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    background: white;
    display: none;
    padding: 15px;
    padding-bottom: 100px;
    max-height: 100%;
    overflow-y: auto;
}

/* Scroll to bottom button */
.scroll-to-bottom {
    position: absolute;
    bottom: 140px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
    z-index: 1000;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.scroll-to-bottom:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.4);
    background: linear-gradient(135deg, #0056b3 0%, #003d82 100%);
}

.scroll-to-bottom i {
    font-size: 18px;
    margin-top: -2px;
}

.scroll-to-bottom.show {
    display: flex;
    animation: bounceIn 0.3s ease;
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }

    50% {
        opacity: 1;
        transform: scale(1.05);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Typing indicator animation */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    font-size: 16px;
    color: #666;
    padding: 10px 0;
}

.typing-dots {
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
}

.typing-dots span {
    height: 8px;
    width: 8px;
    background-color: #999;
    border-radius: 50%;
    display: inline-block;
    margin: 0 2px;
    opacity: 0.4;
    animation: typingDots 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
    animation-delay: 0s;
}

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

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

@keyframes typingDots {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* AI message styling for typing indicator */
.ai-message.typing {
    opacity: 0.8;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.btn-primary {
    background-color: #e47b02;
}

button#new-chat-button {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    background: none;
    border: none;
    font-size: 14px;
}