/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-image: url('bg.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    min-height: 100vh;
    direction: rtl;
    /* Support for devices with notch/safe areas */
    padding-top: env(safe-area-inset-top);
}

/* App container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(10px);
    background-color: rgba(255, 255, 255, 0.1);
}

/* Header */
.header {
    padding: 20px;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.ask-text {
    font-size: 2rem;
    font-weight: bold;
    color: #2c3e50;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    letter-spacing: 2px;
}

.logo {
    height: 60px;
    width: auto;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

/* Chat container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 800px;
    margin: 20px auto;
    padding: 0 20px;
    width: 100%;
    min-height: 0; /* Important for flex children */
}

/* Chat messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
    margin-bottom: 20px;
    min-height: 0; /* Important for flex children */
}

.message {
    margin-bottom: 15px;
    display: flex;
    align-items: flex-start;
}

.bot-message {
    justify-content: flex-start;
}

.user-message {
    justify-content: flex-end;
}

.message-content {
    max-width: 70%;
    padding: 15px 20px;
    border-radius: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    line-height: 1.5;
}

.bot-message .message-content {
    background-color: rgba(255, 255, 255, 0.9);
    border-bottom-right-radius: 5px;
    color: #2c3e50;
}

.user-message .message-content {
    background-color: rgba(52, 152, 219, 0.9);
    border-bottom-left-radius: 5px;
    color: white;
}

.message-content p {
    margin-bottom: 8px;
}

.message-content p:last-child {
    margin-bottom: 0;
}

/* Chat input */
.chat-input-container {
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    border-radius: 25px;
    padding: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0; /* Prevent input from shrinking */
}

.chat-input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 12px 20px;
    font-size: 16px;
    background: transparent;
    color: #2c3e50;
    direction: rtl;
}

.chat-input::placeholder {
    color: #7f8c8d;
    opacity: 0.7;
}

.send-button {
    background-color: #3498db;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
}

.send-button:hover {
    background-color: #2980b9;
    transform: scale(1.05);
}

.send-button:active {
    transform: scale(0.95);
}

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

.chat-messages::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Responsive design */
@media (max-width: 768px) {
    /* Fix for mobile viewport */
    .app-container {
        padding: 0;
        min-height: 100vh;
        height: 100vh;
        overflow: hidden;
    }
    
    .header {
        padding: 15px;
        flex-shrink: 0;
    }
    
    .ask-text {
        font-size: 1.5rem;
    }
    
    .logo {
        height: 50px;
    }
    
    .chat-container {
        margin: 10px;
        padding: 0 10px;
        min-height: 0;
        height: calc(100vh - 120px); /* Account for header height */
        padding-bottom: 160px; /* Increased even more to account for higher input position */
    }
    
    .chat-messages {
        padding: 10px 0;
        margin-bottom: 15px;
        height: calc(100% - 160px); /* Adjusted to account for much higher input position */
    }
    
    .message-content {
        max-width: 85%;
        padding: 12px 15px;
    }
    
    .chat-input-container {
        position: fixed;
        bottom: 120px; /* Raised much higher to be above browser navigation bar */
        left: 20px;
        right: 20px;
        margin: 0;
        z-index: 1000;
        /* Add safe area for iPhone notch */
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
    
    .chat-input {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 10px 15px;
    }
    
    .send-button {
        width: 40px;
        height: 40px;
    }
    
    /* Fix for keyboard on mobile */
    .chat-input:focus {
        /* Ensure input stays visible when keyboard opens */
        transform: translateY(0);
    }
    
    /* Additional spacing to prevent content hiding behind fixed input */
    .chat-messages::after {
        content: '';
        display: block;
        height: 40px; /* Increased spacing */
    }
}

/* Animation for new messages */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message {
    animation: slideIn 0.3s ease-out;
}

/* Loading animation */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 15px 20px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #7f8c8d;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
.typing-dot:nth-child(3) { animation-delay: 0s; }

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

/* Message content styling */
.message-content h4 {
    margin: 10px 0 5px 0;
    color: #2c3e50;
    font-size: 1.1em;
    font-weight: bold;
}

.message-content strong {
    font-weight: bold;
    color: #2c3e50;
}

.message-content a {
    color: #3498db;
    text-decoration: none;
    border-bottom: 1px solid #3498db;
}

.message-content a:hover {
    background-color: rgba(52, 152, 219, 0.1);
    border-radius: 3px;
    padding: 2px;
}

/* Map link button */
.map-link {
    background-color: #27ae60;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 0.9em;
    margin: 5px 0;
    transition: all 0.3s ease;
    display: inline-block;
}

.map-link:hover {
    background-color: #229954;
    transform: scale(1.05);
}

/* Disabled input styling */
.chat-input:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #95a5a6;
}

.send-button:disabled:hover {
    transform: none;
    background-color: #95a5a6;
}