/* Settings Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    overflow-y: auto;
}

.modal-content {
    background-color: var(--primary-color);
    margin: 5% auto;
    padding: 20px;
    border-radius: 8px;
    max-width: 600px;
    max-height: 85vh;
    position: relative;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--primary-color);
    position: sticky;
    top: 0;
    z-index: 10;
    width: 100%;
}

.modal-header h2 {
    margin: 0;
    color: var(--text-color);
    font-size: 1.5rem;
}

.close {
    color: var(--text-color);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.close:hover {
    opacity: 1;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding-right: 10px;
    margin-top: 20px;
    position: relative;
    padding-bottom: 20px;
}

/* Settings Sections */
.settings-section {
    margin-bottom: 30px;
    padding: 20px;
    background: var(--secondary-color);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.settings-section h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--text-color);
    font-size: 1.2rem;
}

/* Form Elements */
.settings-section select,
.settings-section input[type="text"],
.settings-section input[type="password"],
.settings-section input[type="url"] {
    width: 100%;
    padding: 12px;
    background-color: var(--primary-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 15px;
    transition: all 0.2s ease;
}

.settings-section select:focus,
.settings-section input[type="text"]:focus,
.settings-section input[type="password"]:focus,
.settings-section input[type="url"]:focus {
    outline: none;
    border-color: var(--accent-color);
}

.settings-section select:hover,
.settings-section input[type="text"]:hover,
.settings-section input[type="password"]:hover,
.settings-section input[type="url"]:hover {
    border-color: var(--accent-color);
}

.settings-section button {
    padding: 12px 20px;
    background-color: var(--accent-color);
    color: var(--text-color);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.settings-section button:hover {
    background-color: #0d8c6b;
    transform: translateY(-1px);
}

/* Import/Export Controls */
.import-export-controls {
    display: flex;
    gap: 10px;
}

/* Success State */
.settings-save-btn.success {
    background-color: var(--success-color);
    position: relative;
}

/* Save Notification */
.save-notification {
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--accent-color);
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    z-index: 100;
    animation: fadeInOut 3s ease-in-out;
    white-space: nowrap;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateX(-50%) translateY(10px); }
    15% { opacity: 1; transform: translateX(-50%) translateY(0); }
    85% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

/* User Management */
.user-management-controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.add-user-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
}

.add-user-form input,
.add-user-form select {
    margin-bottom: 0;
}

.add-user-form button {
    grid-column: span 2;
}

.user-item {
    display: flex;
    flex-direction: column;
    padding: 12px;
    background-color: var(--primary-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 8px;
    transition: all 0.2s ease;
}

.user-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.user-item:hover {
    border-color: var(--accent-color);
    transform: translateY(-1px);
}

.user-item span {
    color: var(--text-color);
}

.role-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    text-transform: capitalize;
}

.role-badge.admin {
    background-color: var(--accent-color);
}

.role-badge.user {
    background-color: var(--secondary-color);
    border: 1px solid var(--border-color);
}

.delete-user-btn {
    background-color: var(--error-color);
    color: var(--text-color);
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 12px;
    opacity: 0.8;
    transition: all 0.2s ease;
}
.delete-user-btn:hover {
    opacity: 1;
    transform: translateY(-1px);
}

.edit-user-btn {
    background-color: var(--accent-color);
    color: var(--text-color);
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 12px;
    opacity: 0.8;
    transition: all 0.2s ease;
    margin-right: 8px;
}

.edit-user-btn:hover {
    opacity: 1;
    transform: translateY(-1px);
}

.edit-form {
    display: none;
    margin-top: 10px;
    padding: 10px;
    background: var(--secondary-color);
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.edit-form.visible {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.edit-form input,
.edit-form select {
    padding: 8px;
    margin: 0;
    min-width: 150px;
}

.edit-form button {
    padding: 8px 16px;
    font-size: 12px;
    margin: 0;
}

.user-controls {
    display: flex;
    gap: 8px;
}


/* Error Message */
.error-message {
    color: var(--error-color);
    margin-top: 10px;
    font-size: 14px;
    padding: 10px;
    background-color: rgba(255, 59, 48, 0.1);
    border-radius: 4px;
    border: 1px solid var(--error-color);
}

/* Custom Scrollbar */
.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: var(--primary-color);
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

/* Responsive Design */
@media (max-width: 600px) {
    .modal-content {
        margin: 0;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .add-user-form {
        grid-template-columns: 1fr;
    }
    
    .add-user-form button {
        grid-column: 1;
    }

    .modal-body {
        padding-bottom: 20px;
    }
}

/* Profile Modal Styles */
#profileModal .form-section,
#profileModal .training-data-section {
    margin-bottom: 30px;
}

/* File input styling */
.file-input-label {
    display: inline-block;
    padding: 12px 20px;
    background-color: var(--accent-color);
    color: var(--text-color);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
    margin-bottom: 15px;
    text-align: center;
}

.file-input-label:hover {
    background-color: #0d8c6b;
    transform: translateY(-1px);
}

#documentInput {
    width: 0.1px;
    height: 0.1px;
    opacity: 0;
    overflow: hidden;
    position: absolute;
    z-index: -1;
    pointer-events: none;
}

/* Fix for modal content shifting */
.modal-content {
    overflow-y: auto;
    max-height: 85vh;
}

.modal-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: var(--primary-color);
}

.modal-body {
    position: relative;
    overflow-y: auto;
    padding-bottom: 20px;
}

/* Prevent layout shifts when file dialog opens */
.document-upload {
    position: relative;
    margin-bottom: 15px;
}

.stable-layout {
    min-height: 150px;
    display: flex;
    flex-direction: column;
}

.stable-layout .file-input-label {
    align-self: flex-start;
}

.stable-layout .document-list {
    flex: 1;
    min-height: 50px;
}

/* Hide field icons and floating labels */
#profileModal .form-field .field-icon,
#profileModal .form-field label {
    display: none;
}

#profileModal .form-section,
#profileModal .training-data-section {
    margin-bottom: 30px;
    padding: 20px;
    background: var(--secondary-color);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

#profileModal input[type="text"],
#profileModal input[type="url"],
#profileModal textarea {
    width: 100%;
    padding: 12px;
    background-color: var(--primary-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 15px;
    transition: all 0.2s ease;
}

#profileModal textarea {
    min-height: 100px;
    resize: vertical;
}

#profileModal input:focus,
#profileModal textarea:focus {
    outline: none;
    border-color: var(--accent-color);
}

#profileModal input:hover,
#profileModal textarea:hover {
    border-color: var(--accent-color);
}

#profileModal h3,
#profileModal h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--text-color);
    font-size: 1.2rem;
}

#profileModal .document-list,
#profileModal .url-list {
    margin: 15px 0;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px;
    max-height: 150px;
    overflow-y: auto;
}

#profileModal button {
    padding: 12px 20px;
    background-color: var(--accent-color);
    color: var(--text-color);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
    margin-bottom: 15px;
}

#profileModal button:hover {
    background-color: #0d8c6b;
    transform: translateY(-1px);
}

/* Use settings layout classes */
#profileModal .form-section,
#profileModal .training-data-section {
    composes: settings-section;
}
