/* Custom styles */
body {
    background-color: #2f2f2f;
    min-height: 100vh;
    transition: all 0.3s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Modern Effects */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

/* Authentication Section */
#authSection {
    max-width: 500px;
    margin: 20px auto;
    padding: 20px;
}

.card {
    background-color: #383838;
    border: 1px solid #4a4a4a;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    -webkit-backdrop-filter: blur(10px);
            backdrop-filter: blur(10px);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    will-change: transform;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
}

.card-header {
    background-color: #404040;
    border-bottom: 1px solid #4a4a4a;
    color: #e0e0e0;
    position: relative;
    overflow: hidden;
}

.card-footer {
    background-color: #404040;
    border-top: 1px solid #4a4a4a;
}

.form-control {
    background-color: #2f2f2f;
    border: 1px solid #4a4a4a;
    color: #e0e0e0;
    transition: all 0.3s ease;
    border-radius: 8px;
}

.form-control:focus {
    background-color: #2f2f2f;
    border-color: #6c6c6c;
    color: #e0e0e0;
    box-shadow: 0 0 0 3px rgba(90, 90, 90, 0.2);
    transform: translateY(-1px);
}

.form-control::placeholder {
    color: #888;
}

.btn {
    border-radius: 8px;
    padding: 8px 16px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.btn:hover::after {
    width: 300%;
    height: 300%;
}

.btn-primary {
    background-color: #505050;
    border-color: #5a5a5a;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.btn-primary:hover {
    background-color: #5a5a5a;
    border-color: #656565;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn-outline-danger {
    color: #e0e0e0;
    border-color: #5a5a5a;
    position: relative;
    z-index: 1;
}

.btn-outline-danger:hover {
    background-color: #505050;
    border-color: #5a5a5a;
    color: #e0e0e0;
    transform: translateY(-1px);
}

.btn-success {
    background-color: #505050;
    border-color: #5a5a5a;
    color: #e0e0e0;
}

.btn-success:hover {
    background-color: #5a5a5a;
    border-color: #656565;
    color: #e0e0e0;
}

#authSection .card {
    background-color: #343541;
    border: 1px solid #565869;
}

#authSection .card-header {
    background-color: #444654;
    color: #ececf1;
    border-bottom: 1px solid #565869;
}

#authSection .form-control {
    background-color: #3e3f4b;
    border: 1px solid #565869;
    color: #ececf1;
}

#authSection .form-control:focus {
    background-color: #444654;
    color: #ececf1;
    border-color: #6b6c7b;
    box-shadow: 0 0 0 0.25rem rgba(107, 108, 123, 0.25);
}

/* Chat Container */
.chat-container {
    max-width: 800px;
    margin: 20px auto;
    height: calc(100vh - 40px);
    opacity: 0;
    animation: fadeIn 0.5s ease forwards;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-messages {
    height: calc(100vh - 200px);
    overflow-y: auto;
    padding: 15px;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #2f2f2f;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #505050;
    border-radius: 3px;
    transition: background 0.3s ease;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #5a5a5a;
}

.message {
    margin-bottom: 15px;
    padding: 12px 18px;
    border-radius: 12px;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.message:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.user-message {
    background-color: #505050;
    color: #e0e0e0;
    margin-left: auto;
    position: relative;
    animation: slideIn 0.3s ease;
}

.user-message::after {
    content: '';
    position: absolute;
    right: -8px;
    bottom: 15px;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-left-color: #505050;
    border-right: 0;
    margin-right: -8px;
}

.ai-message {
    background-color: #404040;
    color: #e0e0e0;
    margin-right: auto;
    position: relative;
    animation: slideIn 0.3s ease;
}

.ai-message::after {
    content: '';
    position: absolute;
    left: -8px;
    bottom: 15px;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-right-color: #404040;
    border-left: 0;
    margin-left: -8px;
}

.system-message {
    background-color: #383838;
    text-align: center;
    max-width: 100%;
    color: #888;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #4a4a4a;
    animation: pulse 2s infinite;
    backdrop-filter: blur(5px);
}

/* Mobile Fixes */
@media (max-width: 768px) {
    body {
        position: fixed;
        width: 100%;
        height: 100%;
        overflow: hidden;
    }

    #authSection {
        max-height: calc(100vh - 20px);
        overflow-y: auto;
    }
    
    .chat-container {
        margin: 0;
        height: 100vh;
        border-radius: 0;
    }
    
    .chat-messages {
        height: calc(100vh - 120px);
        padding: 10px;
    }
    
    .message {
        max-width: 90%;
        margin-bottom: 10px;
    }
    
    .card-footer {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background-color: #383838;
        z-index: 1000;
        padding: 12px !important;
    }

    .form-control {
        font-size: 16px;
    }

    .btn-send {
        width: 36px;
        height: 36px;
    }

    .btn-send svg {
        width: 16px;
        height: 16px;
    }

    .chat-form {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Chat Input */
.chat-input-container {
    padding: 1rem;
    background-color: #3e3f4b;
    border-top: 1px solid #565869;
}

.chat-form {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    max-width: 800px;
    margin: 0 auto;
    position: relative;
}

.chat-input {
    flex-grow: 1;
    background-color: #444654;
    border: 1px solid #565869;
    border-radius: 8px;
    padding: 0.75rem;
    padding-right: 3rem;
    color: #ececf1;
    resize: none;
    max-height: 200px;
    line-height: 1.5;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.btn-send {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background-color: #10a37f;
    border: none;
    color: white;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.btn-send:hover {
    background-color: #0e916f;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.btn-send:active {
    transform: translateY(0);
}

.btn-send svg {
    width: 18px;
    height: 18px;
    transition: transform 0.3s ease;
}

.btn-send:hover svg {
    transform: translateX(1px);
}

.btn-send:disabled {
    background-color: #565869;
    cursor: not-allowed;
    opacity: 0.7;
}

.btn-send:disabled svg {
    transform: none;
}

.chat-input:focus {
    outline: none;
    border-color: #10a37f;
    box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.2);
}

.chat-submit-btn {
    background-color: #10a37f;
    border: none;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
}

.chat-submit-btn:hover {
    background-color: #0e916f;
}

.chat-submit-btn:disabled {
    background-color: #565869;
    cursor: not-allowed;
}

.send-icon {
    width: 20px;
    height: 20px;
    stroke: #fff;
}

/* Error and Success Messages */
.error-message {
    color: #ff4444;
    background-color: rgba(255, 68, 68, 0.1);
    padding: 0.5rem;
    border-radius: 4px;
    margin-top: 0.5rem;
}

.success-message {
    color: #10a37f;
    background-color: rgba(16, 163, 127, 0.1);
    padding: 0.5rem;
    border-radius: 4px;
    margin-top: 0.5rem;
}

/* Loading States */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #343541;
}

::-webkit-scrollbar-thumb {
    background: #565869;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #6b6c7b;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        background-color: #2f2f2f;
    }

    #authSection {
        margin: 10px;
        padding: 10px;
    }
    
    .chat-container {
        margin: 10px;
        height: calc(100vh - 20px);
        border-radius: 10px;
    }
    
    .chat-messages {
        height: calc(100vh - 180px);
        padding: 10px;
    }
    
    .message {
        max-width: 90%;
        margin-bottom: 10px;
    }
    
    .card-footer {
        padding: 10px;
    }
}
