/* Custom Font */
@font-face {
    font-family: 'Estedad';
    src: url('/static/fonts/Estedad-Light.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

/* Reset and Base Styles */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Estedad', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f5f5f5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    line-height: 1.2;
}

/* Restored Messages and Conversation Divider Styles */
.chat-message.restored {
    opacity: 0.85;
    background-color: rgba(0, 0, 0, 0.02);
    border-left: 3px solid rgba(45, 164, 110, 0.3);
    padding-left: 13px;
}

.chat-message.user.restored {
    border-left: none;
    border-right: 3px solid rgba(0, 122, 255, 0.3);
    padding-right: 13px;
    padding-left: 10px;
}

/* Conversation divider between restored and new messages */
.conversation-divider {
    display: flex;
    align-items: center;
    margin: 20px 10px;
    opacity: 0.6;
    animation: fadeIn 0.5s ease-in;
}

.divider-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, #ccc, transparent);
}

.divider-text {
    padding: 0 15px;
    color: #666;
    font-size: 14px;
    font-style: italic;
    white-space: nowrap;
    background: #f5f5f5;
    border-radius: 12px;
    padding: 4px 12px;
}

/* RTL support for divider */
.rtl .conversation-divider {
    direction: rtl;
}

/* Reconnecting overlay */
.reconnecting-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease-in;
}

.reconnecting-message {
    padding: 30px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    text-align: center;
    max-width: 300px;
}

.reconnecting-spinner {
    margin-bottom: 15px;
}

.reconnecting-text {
    font-size: 18px;
    color: #333;
    font-weight: 600;
    margin-bottom: 5px;
}

.reconnecting-subtext {
    font-size: 16px;
    color: #666;
}

/* Restoration success message */
.restoration-success {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #2da46e;
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    box-shadow: 0 2px 10px rgba(45, 164, 110, 0.3);
    z-index: 101;
    animation: slideDown 0.3s ease-out;
    transition: opacity 0.3s ease;
}

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

@keyframes slideDown {
    from {
        transform: translateX(-50%) translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

/* Version Badge */
.version-badge {
    position: fixed;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-family: 'Monaco', 'Courier New', monospace;
    z-index: 10000;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.version-color-square {
    width: 16px;
    height: 16px;
    background-color: #4CAF50; /* Green - Change this color with each version */
    border-radius: 3px;
    display: inline-block;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.version-text {
    font-weight: 600;
    color: #fff;
}

.version-date {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
}

/* Mobile adjustments for version badge */
@media (max-width: 768px) {
    .version-badge {
        font-size: 12px;
        padding: 5px 8px;
        gap: 6px;
    }
    
    .version-color-square {
        width: 14px;
        height: 14px;
    }
    
    .version-date {
        font-size: 12px;
    }
}


/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Agent Container */
.agent-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    margin-bottom: 40px;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Agent container when chat is active */
.agent-container.chat-active {
    position: fixed;
    top: 20px;
    right: 20px;
    left: auto;
    transform: none;
    margin-bottom: 0;
    gap: 8px;
    z-index: 100;
    align-items: flex-start;
    display: flex;
    flex-direction: row;
    align-items: center;
}

.agent-media {
    width: 220px;
    height: 220px;
    border-radius: 45px;
    overflow: hidden;
    position: relative;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Agent media when chat is active */
.chat-active .agent-media {
    width: 80px;
    height: 80px;
    border-radius: 20px;
}

/* Video/Image Styles */
.agent-video, 
.agent-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.agent-video {
    position: absolute;
    top: 0;
    left: 0;
}

/* Status Text */
.status-text {
    font-size: 30px;
    font-weight: 500;
    color: #333;
    margin: 0;
    text-align: center;
    line-height: 1.3;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Status text when chat is active */
.chat-active .status-text {
    font-size: 18px;
    font-weight: 400;
    opacity: 0.8;
}

/* Action Buttons Container (centered below greeting) */
.action-buttons-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 280px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Controls (for end button during chat) */
.controls {
    position: fixed;
    top: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 50;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Make button smaller when in controls */
.controls .action-button {
    padding: 10px 16px;
    font-size: 16px;
    min-width: auto;
}

/* Make icon smaller too */
.controls .chat-icon {
    width: 16px;
    height: 16px;
}

/* RTL support for controls position */
body.rtl .controls {
    left: auto;
    right: 20px;
}

/* Button Styles */
.action-button {
    padding: 14px 24px;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 20px;
    font-family: inherit;
    line-height: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 160px;
}

/* Primary Button (filled green - Start Chat) */
.action-button.primary-button {
    background-color: #2da46e;
    color: white;
    width: 100%;
    border: none;
    box-shadow: 0 2px 8px rgba(45, 164, 110, 0.3);
}

.action-button.primary-button:hover {
    background-color: #238a56;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(45, 164, 110, 0.4);
}

/* Secondary Button (outlined - My Tickets) */
.action-button.secondary-button {
    background-color: transparent;
    color: #666;
    border: 2px solid #ddd;
    width: 100%;
}

.action-button.secondary-button:hover {
    border-color: #2da46e;
    color: #2da46e;
    transform: translateY(-1px);
}

/* Legacy styles for backwards compatibility */
.action-button.start-call {
    background-color: #2da46e;
    color: white;
    box-shadow: 0 2px 8px rgba(45, 164, 110, 0.3);
}

.action-button.start-call:hover {
    background-color: #238a56;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(45, 164, 110, 0.4);
}

.action-button.tickets-button {
    background-color: transparent;
    color: #666;
    border: 2px solid #ddd;
}

.action-button.tickets-button:hover {
    border-color: #2da46e;
    color: #2da46e;
    transform: translateY(-1px);
}

.action-button.end-call {
    background-color: black;
    color: white;
    position: fixed;
    top: 20px;
    left: 20px;
    right: auto;
    z-index: 1000;
    height: 48px;
    display: flex;
    align-items: center;
}

.action-button.end-call:hover {
    background-color: #222;
    transform: translateY(-1px);
}

.action-button:active {
    transform: translateY(0);
}

/* Button Icons */
.mic-icon,
.chat-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.action-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.button-icon {
    font-size: 22px;
}

/* Photo Documentation Button */
.photo-documentation {
    margin-top: 20px;
    width: 100%;
    max-width: 320px;
}

.action-button.photo-doc {
    background-color: #4CAF50;
    color: white;
    width: 100%;
}

.action-button.photo-doc:hover {
    background-color: #45a049;
}

/* Language Selector Container */
.language-selector-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 50;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.language-selector-container.hidden {
    opacity: 0;
    visibility: hidden;
}

/* Language Button */
.lang-button {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: white;
    color: black;
    border: 2px solid rgba(0, 0, 0, 0.1);
    font-size: 20px;
    font-weight: 600;
    font-family: inherit;
    line-height: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.lang-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Hidden class */
.hidden {
    display: none !important;
}

/* RTL support for Arabic */
[lang="ar"] {
    direction: rtl;
}

body.rtl {
    direction: rtl;
}

body.rtl .language-selector-container {
    left: 30px;
    right: auto;
}

body.rtl .controls {
    right: 30px;
    left: auto;
}

/* Ensure center alignment even in RTL mode */
body.rtl .agent-container,
body.rtl .status-text {
    text-align: center;
}

/* RTL support for agent container when chat is active */
body.rtl .agent-container.chat-active {
    right: auto;
    left: 20px;
}

/* RTL support for buttons */
[dir="rtl"] .action-button {
    flex-direction: row-reverse;
}

/* RTL support for end button position */
body.rtl .action-button.end-call {
    left: auto;
    right: 20px;
}

/* Responsive styles */
@media (max-width: 600px) {
    .main-content {
        padding: 16px;
    }

    .agent-media {
        width: 180px;
        height: 180px;
        border-radius: 40px;
    }

    .chat-active .agent-media {
        width: 60px;
        height: 60px;
        border-radius: 16px;
    }

    .status-text {
        font-size: 24px;
        padding: 0 16px;
    }

    .chat-active .status-text {
        font-size: 16px;
    }

    /* Action buttons container mobile */
    .action-buttons-container {
        max-width: 260px;
        padding: 0 16px;
    }

    .controls {
        top: 10px;
        left: 10px;
    }

    body.rtl .controls {
        right: 10px;
        left: auto;
    }

    /* Make button smaller on mobile */
    .controls .action-button {
        padding: 8px 12px;
        font-size: 16px;
    }

    .controls .chat-icon {
        width: 14px;
        height: 14px;
    }

    .action-button {
        padding: 12px 20px;
        font-size: 18px;
        min-width: 140px;
    }

    .mic-icon,
    .chat-icon {
        width: 18px;
        height: 18px;
    }

    .language-selector-container {
        bottom: 20px;
        right: 20px;
    }

    body.rtl .language-selector-container {
        left: 20px;
        right: auto;
    }

    .lang-button {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }

    /* Chat responsive styles */
    .chat-container {
        height: 250px;
        max-width: 100%;
    }

    .chat-container.visible {
        top: 80px; /* Smaller agent image on mobile */
    }

    .chat-message {
        max-width: 80%;
        font-size: 18px;
    }

    .chat-input {
        font-size: 18px;
        padding: 8px 12px;
    }

    .send-button {
        width: 36px;
        height: 36px;
    }
}

/* Chat Container Styles */
.chat-container {
    width: 100%;
    max-width: 600px;
    height: 300px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Support for iOS safe areas */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .chat-container {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Chat container when visible */
.chat-container.visible {
    opacity: 1;
    transform: translateY(0);
    position: fixed;
    top: 80px; /* Below agent image */
    bottom: 0;
    left: 0;
    right: 0;
    height: auto;
    max-width: 100%;
    border-radius: 16px 16px 0 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-message {
    max-width: 70%;
    padding: 10px 16px;
    border-radius: 16px;
    word-wrap: break-word;
    animation: fadeIn 0.3s ease-out;
    font-size: 18px;
}

.chat-message.user {
    align-self: flex-end;
    background-color: #2da46e;
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.user a {
    color: #b3e8d1;
    text-decoration: underline;
}

.chat-message.user a:hover {
    color: #d4f3e6;
}

.chat-message.agent {
    align-self: flex-start;
    background-color: #f1f1f1;
    color: #333;
    border-bottom-left-radius: 4px;
}

.chat-message.agent a {
    color: #2da46e;
    text-decoration: underline;
}

.chat-message.agent a:hover {
    color: #238756;
    text-decoration: underline;
}

.chat-input-container {
    display: flex;
    padding: 12px;
    gap: 8px;
    border-top: 1px solid #eee;
    background-color: #f9f9f9;
    padding-bottom: 32px;
}

.chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 18px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease;
}

.chat-input:focus {
    border-color: #2da46e;
}

.chat-input:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
}

.send-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #2da46e;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
    background-color: #238a56;
    transform: scale(1.05);
}

.send-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Send button SVG */
.send-button svg {
    transition: transform 0.2s ease;
}

/* Flip send arrow in RTL mode */
[dir="rtl"] .send-button svg,
body.rtl .send-button svg {
    transform: rotateY(180deg);
}

/* RTL support for chat */
body.rtl .chat-message.user {
    align-self: flex-start;
    border-bottom-right-radius: 4px;
    border-bottom-left-radius: 16px;
}

body.rtl .chat-message.agent {
    align-self: flex-end;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 16px;
}

body.rtl .chat-input {
    text-align: right;
}


/* Scrollbar styling */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

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

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #555;
}

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

.agent-container {
    animation: fadeIn 0.5s ease-out;
}

/* Smooth transitions */
.agent-video,
.agent-image {
    transition: opacity 0.3s ease;
}

/* Loading state */
.agent-media.loading {
    background: #f0f0f0;
}

.agent-media.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid #ddd;
    border-top-color: #4CAF50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Mute Button Container */
.mute-button-container {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    display: block;
    width: auto;
    margin: 0;
}

/* Mute Button */
.mute-button {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: white;
    color: black;
    border: 2px solid rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.mute-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.mute-button.muted {
    background-color: #ff4444;
    color: white;
    border-color: rgba(255, 68, 68, 0.2);
}

.mute-icon {
    width: 24px;
    height: 24px;
}

/* RTL support for mute button - stays centered */
body.rtl .mute-button-container {
    /* Mute button remains centered in RTL mode */
    left: 50%;
    right: auto;
    transform: translateX(-50%);
}

/* Responsive styles for mute button */
@media (max-width: 768px) {
    .mute-button-container {
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
    }
    
    body.rtl .mute-button-container {
        /* Mute button remains centered in RTL mode */
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }
    
    .mute-button {
        width: 45px;
        height: 45px;
    }
    
    .mute-icon {
        width: 20px;
        height: 20px;
    }
}