:root {
    --primary-color: #8eb533;
    --secondary-color: #3498db;
    --danger-color: #e74c3c;
    --dark-bg: #1a1a1a;
    --light-bg: #f8f9fa;
    --text-dark: #333333;
    --text-light: #666666;
    --border-color: #e0e0e0;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.main-content {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-dark);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 2rem;
    text-align: center;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    border-radius: 50px;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Main Content */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    padding: 0 1rem;
    margin-bottom: 2rem;
    margin: 20px auto;
    width: 80%;
}

/* Chat Container */
.chat-container {
    background: white;
    border-radius: 50px;
    /* box-shadow: var(--shadow); */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background-color: #fafafa;
    max-height: 500px;
}

.message {
    margin-bottom: 1.5rem;
    animation: slideIn 0.3s ease-in-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bot-message .message-content {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem;
    border-radius: 50px;
    max-width: 80%;
}

.bot-message .message-content > *:not(img) {
    margin-left: 0.5rem;
    margin-right: 0.5rem;
}

.bot-message .message-content > *:first-child:not(img) {
    margin-top: 0.5rem;
}

/* .bot-message .message-content > *:last-child:not(img) {
    margin-bottom: 0.5rem;
} */

.bot-message .message-content img {
    max-width: 100%;
    height: auto;
    border-radius: 50px;
    margin-bottom: 0.5rem;
    margin-left: 0;
    margin-right: 0;
}

.bot-message .message-content img:last-child {
    margin-bottom: 0;
}

.user-message .message-content {
    background-color: var(--secondary-color);
    color: white;
    padding: 1rem;
    border-radius: 50px;
    max-width: 80%;
    margin-left: auto;
}

.user-message .message-content > *:not(img) {
    margin-left: 0.5rem;
    margin-right: 0.5rem;
}

.user-message .message-content > *:first-child:not(img) {
    margin-top: 0.5rem;
}

.user-message .message-content > *:last-child:not(img) {
    margin-bottom: 0.5rem;
}

.message-content p {
    margin-bottom: 0.5rem;
}

.message-content p:last-child {
    margin-bottom: 0;
}

/* Form Styles */
.chat-input-area {
    padding: 1.5rem;
    background-color: white;
    border-top: 1px solid var(--border-color);
}

.generation-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 0.95rem;
}

.file-input-label {
    cursor: pointer;
    padding: 1.5rem;
    border: 2px dashed var(--primary-color);
    border-radius: 50px;
    text-align: center;
    background-color: rgba(142, 181, 51, 0.05);
    transition: all 0.3s ease;
}

.file-input-label:hover {
    background-color: rgba(142, 181, 51, 0.1);
    border-color: var(--primary-color);
}

.file-input-label input[type="file"] {
    display: none;
}

.label-text {
    display: block;
    font-weight: 600;
    color: var(--primary-color);
}

.file-name {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-light);
}

select,
textarea {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 50px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.3s ease;
}

select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(142, 181, 51, 0.1);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 50px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: #7ba32a;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(142, 181, 51, 0.3);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Loader */
.loader {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* User Info */
.user-info {
    padding: 1rem;
    background-color: #f5f5f5;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.user-info input {
    flex: 1;
    min-width: 150px;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 50px;
    font-size: 0.85rem;
}

.limit-info {
    font-size: 0.85rem;
    color: var(--text-light);
    padding: 0.5rem;
    background-color: white;
    border-radius: 50px;
    /* border-left: 3px solid var(--primary-color); */
    padding-left: 0.75rem;
}

/* History Container */
.history-container {
    background: white;
    border-radius: 50px;
    /* box-shadow: var(--shadow); */
    padding: 1.5rem;
    overflow: auto;
    max-height: 600px;
}

.history-container h2 {
    margin-bottom: 1rem;
    color: var(--text-dark);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.history-item {
    padding: 1rem;
    background-color: #fafafa;
    border-radius: 50px;
    /* border-left: 3px solid var(--primary-color); */
    cursor: pointer;
    transition: all 0.3s ease;
}

.history-item:hover {
    background-color: #f0f0f0;
    transform: translateX(5px);
}

.history-item-style {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.history-item-date {
    font-size: 0.8rem;
    color: var(--text-light);
}

.empty-message {
    text-align: center;
    color: var(--text-light);
    padding: 2rem;
    font-style: italic;
}

/* Error/Success Messages */
.alert {
    padding: 1rem;
    border-radius: 50px;
    margin-bottom: 1rem;
    animation: slideIn 0.3s ease-in-out;
}

.alert-error {
    background-color: #fadbd8;
    color: #a93226;
    /* border-left: 3px solid var(--danger-color); */
}

.alert-success {
    background-color: #d5f4e6;
    color: #27ae60;
    /* border-left: 3px solid var(--primary-color); */
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
    border-top: 1px solid var(--border-color);
}

/* Action Buttons Container */
.action-buttons-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 15px 0;
    padding: 15px;
    background-color: rgba(142, 181, 51, 0.05);
    border-radius: 50px;
    /*border-left: 3px solid var(--primary-color); */
}

.action-button {
    padding: 12px 16px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
}

.action-button:hover:not(:disabled) {
    background-color: #7ba32a;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(142, 181, 51, 0.3);
}

.action-button:active:not(:disabled) {
    transform: translateY(0);
}

.action-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.button-loader {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .header h1 {
        font-size: 1.8rem;
    }

    .chat-messages {
        max-height: 300px;
    }

    .history-container {
        max-height: 400px;
    }

    .bot-message .message-content,
    .user-message .message-content {
        max-width: 95%;
    }

    .container {
        padding: 0;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .header p {
        font-size: 0.9rem;
    }

    .main-content {
        padding: 0;
        gap: 1rem;
    }

    .chat-container,
    .history-container {
        border-radius: 0;
    }

    .user-info {
        flex-direction: column;
    }

    .user-info input {
        min-width: 100%;
    }
}

/* Auth Section Styles */
.auth-section {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 50px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.auth-mode-toggle {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.auth-mode-toggle label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: #666;
}

.auth-mode-toggle input[type="radio"] {
    margin: 0;
}

.auth-input-section {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.auth-input-section input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 50px;
    font-size: 0.9rem;
}

.btn-secondary {
    background: #6c757d;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-secondary:disabled {
    background: #adb5bd;
    cursor: not-allowed;
}

@media (max-width: 768px) {
    .auth-input-section {
        flex-direction: column;
        align-items: stretch;
    }
    
    .auth-input-section button {
        width: 100%;
    }
}