/* Color classes */
.bg-svenska-blue {
    background-color: #0066cc;
}

.bg-svenska-blue-darker {
    background-color: #0052a3;
}

.text-svenska-blue {
    color: #0066cc;
}

.hidden {
    display: none;
}

.chatbox {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 3%;
    width: 100vw;
    margin: 0 auto;
    /* border-radius: 0.75rem 0.75rem 0 0; */
    /* box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); */
    display: flex;
    flex-direction: column;
    color: white;
    overflow: hidden;
    z-index: 1000;
    max-width: 100vw;
}

.chatbox-header {
    padding: 1rem;
    /* p-4 */
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* Uses .border-chatbox-svenska-accent */
    border-bottom-width: 1px;
}

.chatbox-header-title {
    display: flex;
    align-items: center;
    font-weight: 500;
    /* medium */
}

.chatbox-body {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding: 1rem;
    /* p-4 */
    overflow-y: auto;
}

.mic-button {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.2);
    /* Semi-transparent white */
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.mic-button:hover:not(.disabled) {
    background-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.mic-button.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background-color: rgba(128, 128, 128, 0.2);
}

.mic-active {
    background-color: rgba(239, 68, 68, 0.5);
    /* Semi-transparent red */
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.4);
    animation: micPulse 1.5s ease-in-out infinite;
}

@keyframes micPulse {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(239, 68, 68, 0.4);
    }

    50% {
        box-shadow: 0 0 30px rgba(239, 68, 68, 0.6);
    }
}

/* Tool Usage Indicator */
.tool-indicator {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    transition: all 0.3s ease;
}

.tool-indicator.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(-20px);
}

.tool-indicator-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.95) 0%, rgba(118, 75, 162, 0.95) 100%);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    animation: toolPulse 2s ease-in-out infinite;
}

.tool-icon {
    font-size: 1.25rem;
    animation: toolSpin 2s linear infinite;
}

.tool-text {
    font-size: 0.95rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    letter-spacing: 0.025em;
}

@keyframes toolPulse {

    0%,
    100% {
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    }

    50% {
        box-shadow: 0 8px 24px rgba(102, 126, 234, 0.5);
    }
}

@keyframes toolSpin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Connection Status Indicator */
.connection-status {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #6b7280;
    transition: all 0.3s ease;
}

.status-indicator.connecting .status-dot {
    background: #fbbf24;
    animation: pulse 1.5s ease-in-out infinite;
}

.status-indicator.connected .status-dot {
    background: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.status-indicator.listening .status-dot {
    background: #3b82f6;
    animation: pulse 1s ease-in-out infinite;
}

.status-indicator.disconnected .status-dot {
    background: #ef4444;
}

.status-text {
    font-size: 0.875rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    letter-spacing: 0.025em;
}

@keyframes pulse {

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

    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

.chatbox-footer {
    padding: 1rem;
    /* p-4 */
    display: flex;
    justify-content: space-around;
    align-items: center;
    /* Uses .border-chatbox-svenska-accent */
    border-top-width: 1px;
}

.chat-control-btn {
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}

.chat-control-btn:hover {
    background-color: rgba(255, 255, 255, 0.25);
}

.chat-control-btn.end-call {
    background-color: #DC2626;
    /* Red for end call */
}

.chat-control-btn.end-call:hover {
    background-color: #EF4444;
    /* Lighter red on hover */
}

/* Chat message bubbles - Subtitle style */
.chat-message {
    max-width: 70%;
    margin: 0 auto 8px auto;
    padding: 8px 16px;
    border-radius: 16px;
    word-wrap: break-word;
    font-size: 0.9rem;
    line-height: 1.4;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease-out;
    backdrop-filter: blur(8px);
}

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

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

.user-message {
    background: rgba(102, 126, 234, 0.25);
    color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(102, 126, 234, 0.3);
    font-size: 0.85rem;
}

.assistant-message {
    background: rgba(0, 0, 0, 0.6);
    color: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    font-weight: 500;
}

/* Fadeout animation for old messages */
.chat-message.fading-out {
    animation: fadeOut 1s ease-out forwards;
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* Audio wave animation */
.audio-wave {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 20px;
    margin: 10px 0;
}

.audio-wave span {
    display: inline-block;
    width: 3px;
    height: 100%;
    margin: 0 2px;
    background-color: rgba(255, 255, 255, 0.7);
    border-radius: 3px;
    animation: wave 1.2s infinite ease-in-out;
}

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

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

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

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

@keyframes wave {

    0%,
    40%,
    100% {
        transform: scaleY(0.4);
    }

    20% {
        transform: scaleY(1);
    }
}

/* Custom scrollbar for webkit browsers */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    /* Light gray track */
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: #0051BA;
    /* Primary Blue scrollbar thumb */
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #003A8C;
    /* Darker Blue on hover */
}

/* Tool Loading Dialog Styles */
.tool-loading-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.tool-loading-content {
    background: linear-gradient(135deg, #0066cc, #0052a3);
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    max-width: 320px;
    width: 90%;
    color: white;
}

.tool-loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1.5rem;
    position: relative;
    width: 60px;
    height: 60px;
    margin: 0 auto 1.5rem auto;
}

.spinner-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid transparent;
    border-top: 3px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    animation: spin 1.2s linear infinite;
}

.spinner-ring:nth-child(2) {
    width: 80%;
    height: 80%;
    top: 10%;
    left: 10%;
    animation-delay: -0.4s;
    border-top-color: rgba(255, 255, 255, 0.6);
}

.spinner-ring:nth-child(3) {
    width: 60%;
    height: 60%;
    top: 20%;
    left: 20%;
    animation-delay: -0.8s;
    border-top-color: rgba(255, 255, 255, 0.4);
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.tool-loading-text h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: white;
}

.tool-loading-text p {
    font-size: 0.875rem;
    opacity: 0.9;
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
}

/* Language Selection Dialog */
.language-dialog,
.retry-dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.language-dialog.hidden,
.retry-dialog.hidden {
    display: none;
}

.language-dialog-content,
.retry-dialog-content {
    background: linear-gradient(145deg, rgba(30, 30, 40, 0.95) 0%, rgba(20, 20, 30, 0.95) 100%);
    border-radius: 20px;
    padding: 2rem;
    min-width: 320px;
    max-width: 90vw;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.language-dialog-header h3 {
    font-size: 1.5rem;
    margin: 0 0 0.5rem 0;
    color: white;
}

.language-dialog-header p {
    margin: 0 0 1.5rem 0;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
}

.language-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.language-option {
    padding: 1rem 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.language-option:hover {
    background: rgba(102, 126, 234, 0.3);
    border-color: rgba(102, 126, 234, 0.5);
    transform: scale(1.02);
}

.language-cancel-btn {
    padding: 0.75rem 2rem;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.language-cancel-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Retry Dialog */
.retry-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.retry-dialog-content h3 {
    font-size: 1.3rem;
    margin: 0 0 0.5rem 0;
    color: white;
}

.retry-dialog-content p {
    margin: 0 0 1.5rem 0;
    color: rgba(255, 255, 255, 0.6);
}

.retry-btn {
    padding: 1rem 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.retry-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}