/* Backoffice Admin Panel - Dr. Hadish */

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: #f8fafc;
    color: #333;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: white;
    border-right: 1px solid #e0e6ed;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid #e0e6ed;
    background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
    color: white;
}

.sidebar-header h1 {
    font-size: 1.5rem;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-header p {
    opacity: 0.9;
    font-size: 0.9rem;
}

.nav-menu {
    flex: 1;
    padding: 20px 0;
}

.nav-item {
    padding: 14px 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #2c3e50;
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
}

.nav-item:hover {
    background: #f8f9fa;
    color: #9b59b6;
}

.nav-item.active {
    background: #f3e8ff;
    color: #9b59b6;
    border-left-color: #9b59b6;
}

.nav-item i {
    width: 20px;
    text-align: center;
}

.user-info {
    padding: 20px 24px;
    border-top: 1px solid #e0e6ed;
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

.user-details h4 {
    color: #2c3e50;
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.user-details p {
    color: #7f8c8d;
    font-size: 0.85rem;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f8fafc;
    overflow: hidden;
}

.top-bar {
    background: white;
    padding: 16px 24px;
    border-bottom: 1px solid #e0e6ed;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.top-bar h2 {
    color: #2c3e50;
    font-size: 1.3rem;
}

.top-bar-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.search-box {
    position: relative;
}

.search-box input {
    border: 1px solid #e0e6ed;
    border-radius: 6px;
    padding: 8px 12px 8px 36px;
    font-size: 0.9rem;
    width: 250px;
    outline: none;
    transition: border-color 0.3s ease;
}

.search-box input:focus {
    border-color: #9b59b6;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #7f8c8d;
}

.notification-btn {
    background: white;
    border: 1px solid #e0e6ed;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #e74c3c;
    color: white;
    font-size: 0.7rem;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Content Area */
.content-area {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

/* Dashboard Overview */
.dashboard-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    border: 1px solid #e0e6ed;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.icon-users {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
}

.icon-consultations {
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
}

.icon-documents {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

.icon-system {
    background: linear-gradient(135deg, #f39c12 0%, #d35400 100%);
}

.stat-info h3 {
    font-size: 1.8rem;
    color: #2c3e50;
    margin-bottom: 4px;
}

.stat-info p {
    color: #7f8c8d;
    font-size: 0.9rem;
}

/* Management Sections */
.management-section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    border: 1px solid #e0e6ed;
    margin-bottom: 24px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f8f9fa;
}

.section-header h3 {
    color: #2c3e50;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-actions {
    display: flex;
    gap: 8px;
}

.language-select {
    border: 1px solid #e0e6ed;
    border-radius: 8px;
    padding: 6px 10px;
    background: #ffffff;
    color: #2c3e50;
    font-size: 0.9rem;
}

.rtl {
    direction: rtl;
}

.action-btn {
    background: white;
    border: 1px solid #e0e6ed;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    color: #2c3e50;
    transition: all 0.3s ease;
}

.action-btn:hover {
    border-color: #9b59b6;
    color: #9b59b6;
}

.action-btn.primary {
    background: #9b59b6;
    color: white;
    border-color: #9b59b6;
}

.action-btn.primary:hover {
    background: #8e44ad;
}

.action-btn.danger {
    border-color: #e74c3c;
    color: #e74c3c;
}

.action-btn.danger:hover {
    background: #e74c3c;
    color: #ffffff;
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background: #f8f9fa;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #2c3e50;
    border-bottom: 2px solid #e0e6ed;
    font-size: 0.9rem;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #e0e6ed;
    color: #2c3e50;
    font-size: 0.9rem;
}

.data-table tr:hover {
    background: #f8f9fa;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-block;
}

.status-active {
    background: #d5f4e6;
    color: #27ae60;
}

.status-inactive {
    background: #ffeaea;
    color: #e74c3c;
}

.status-pending {
    background: #fff3cd;
    color: #856404;
}

.action-buttons {
    display: flex;
    gap: 8px;
}

.table-btn {
    background: white;
    border: 1px solid #e0e6ed;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    color: #2c3e50;
    transition: all 0.3s ease;
}

.table-btn:hover {
    border-color: #9b59b6;
    color: #9b59b6;
}

/* File Manager */
.file-manager {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.file-card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 16px;
    border: 1px solid #e0e6ed;
    cursor: pointer;
    transition: all 0.3s ease;
}

.file-card:hover {
    border-color: #9b59b6;
    box-shadow: 0 4px 12px rgba(155, 89, 182, 0.1);
}

.file-icon {
    color: #9b59b6;
    font-size: 2rem;
    margin-bottom: 12px;
}

.file-info h4 {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 4px;
    font-size: 0.95rem;
}

.file-info p {
    color: #7f8c8d;
    font-size: 0.85rem;
    line-height: 1.4;
}

.indexing-progress {
    margin-top: 8px;
    width: 100%;
    height: 6px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 999px;
    overflow: hidden;
}

.indexing-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #f39c12, #f1c40f);
    transition: width 0.3s ease;
}

.file-actions {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
}

/* System Settings */
.settings-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 500;
    color: #2c3e50;
}

.form-group input,
.form-group select,
.form-group textarea {
    border: 1px solid #e0e6ed;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #9b59b6;
    box-shadow: 0 0 0 3px rgba(155, 89, 182, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-group input {
    width: 18px;
    height: 18px;
}

.save-settings {
    background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition:
        transform 0.3s ease,
        box-shadow 0.3s ease;
    margin-top: 10px;
}

.save-settings:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(155, 89, 182, 0.3);
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid #e0e6ed;
    }

    .nav-menu {
        display: flex;
        overflow-x: auto;
        padding: 10px 0;
    }

    .nav-item {
        flex-shrink: 0;
        padding: 10px 16px;
    }

    .top-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .search-box input {
        width: 100%;
    }
}

/* Upload Modal */
.upload-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(3px);
    animation: fadeIn 0.3s ease;
}

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

.upload-modal {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid #e0e6ed;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
    color: white;
    border-radius: 12px 12px 0 0;
}

.modal-header h3 {
    font-size: 1.3rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.modal-content {
    padding: 24px;
}

/* Drag & Drop Area */
.drag-drop-area {
    border: 3px dashed #d1d8e0;
    border-radius: 12px;
    padding: 60px 30px;
    text-align: center;
    background: #f8fafc;
    margin-bottom: 24px;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.drag-drop-area:hover {
    border-color: #9b59b6;
    background: #f3e8ff;
}

.drag-drop-area.drag-over {
    border-color: #9b59b6;
    background: #e8d6ff;
    transform: scale(1.02);
}

.drag-drop-icon {
    font-size: 48px;
    color: #9b59b6;
    margin-bottom: 16px;
}

.drag-drop-text h4 {
    font-size: 1.2rem;
    margin-bottom: 8px;
    color: #333;
}

.drag-drop-text p {
    color: #7f8c8d;
    margin-bottom: 16px;
}

.browse-btn {
    display: inline-block;
    background: #9b59b6;
    color: white;
    padding: 10px 24px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    transition:
        background 0.2s,
        transform 0.2s;
}

.browse-btn:hover {
    background: #8e44ad;
    transform: translateY(-2px);
}

.file-input {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    cursor: pointer;
}

/* File List Preview */
.file-list {
    margin-top: 20px;
}

.file-item {
    display: flex;
    align-items: center;
    padding: 12px;
    background: white;
    border: 1px solid #e0e6ed;
    border-radius: 8px;
    margin-bottom: 10px;
    transition: all 0.2s;
}

.file-item:hover {
    border-color: #9b59b6;
    box-shadow: 0 4px 12px rgba(155, 89, 182, 0.1);
}

.file-icon {
    width: 40px;
    height: 40px;
    background: #f3e8ff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9b59b6;
    margin-right: 12px;
}

.file-info {
    flex: 1;
}

.file-name {
    font-weight: 500;
    margin-bottom: 4px;
    word-break: break-all;
}

.file-size {
    font-size: 0.85rem;
    color: #7f8c8d;
}

.file-remove {
    background: none;
    border: none;
    color: #e74c3c;
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    transition: background 0.2s;
}

.file-remove:hover {
    background: #ffeaea;
}

/* Upload Form */
.upload-form {
    margin-top: 24px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.upload-form-group {
    margin-bottom: 20px;
}

.upload-form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
}

.upload-form-group input,
.upload-form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #d1d8e0;
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.upload-form-group input:focus,
.upload-form-group textarea:focus {
    outline: none;
    border-color: #9b59b6;
    box-shadow: 0 0 0 3px rgba(155, 89, 182, 0.1);
}

.upload-form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.form-select {
    width: 100%;
    padding: 12px;
    border: 1px solid #d1d8e0;
    border-radius: 6px;
    font-size: 0.95rem;
    background: #fff;
    transition: border-color 0.2s;
}

.form-select:focus {
    outline: none;
    border-color: #9b59b6;
    box-shadow: 0 0 0 3px rgba(155, 89, 182, 0.1);
}

.modal-error {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 6px;
    background: #fdecea;
    color: #c0392b;
    font-size: 0.9rem;
    border: 1px solid #f5c6cb;
}

/* Progress Bar */
.upload-progress {
    margin: 20px 0;
    background: #e0e6ed;
    border-radius: 10px;
    height: 8px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #9b59b6, #8e44ad);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 10px;
}

.progress-text {
    text-align: center;
    color: #7f8c8d;
    font-size: 0.9rem;
    margin-bottom: 20px;
}

/* Modal Actions */
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid #e0e6ed;
}

.modal-btn {
    padding: 12px 24px;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.modal-btn.primary {
    background: #9b59b6;
    color: white;
}

.modal-btn.primary:hover {
    background: #8e44ad;
    transform: translateY(-2px);
}

.modal-btn.secondary {
    background: #f8fafc;
    color: #333;
    border: 1px solid #d1d8e0;
}

.modal-btn.secondary:hover {
    background: #e0e6ed;
}

/* Upload Status */
.upload-status {
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    text-align: center;
}

.upload-status.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.upload-status.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.upload-status.processing {
    background: #cce5ff;
    color: #004085;
    border: 1px solid #b8daff;
}

.status-icon {
    font-size: 24px;
    margin-bottom: 10px;
}

.prompt-details {
    margin-top: 16px;
    background: #f8fafc;
    border: 1px solid #e0e6ed;
    border-radius: 10px;
    padding: 12px 14px;
}

.prompt-details h5 {
    margin: 0 0 10px;
    font-size: 0.95rem;
    color: #2c3e50;
}

.prompt-detail {
    padding: 8px 0;
    border-top: 1px solid #e9edf3;
}

.prompt-detail:first-of-type {
    border-top: none;
}

.prompt-detail-title {
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.9rem;
}

.prompt-detail-desc {
    color: #5f6c7b;
    font-size: 0.85rem;
    line-height: 1.4;
    margin-top: 4px;
}

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

html[dir="rtl"] .toast-container {
    right: auto;
    left: 24px;
}

.toast {
    min-width: 220px;
    max-width: 360px;
    padding: 10px 14px;
    border-radius: 10px;
    color: #1f2a37;
    background: #f8fafc;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.18);
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-info {
    border-left: 4px solid #3b82f6;
}

.toast-warning {
    border-left: 4px solid #f59e0b;
    background: #fff7ed;
}

.toast-error {
    border-left: 4px solid #ef4444;
    background: #fef2f2;
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(155, 89, 182, 0.3);
    border-radius: 50%;
    border-top-color: #9b59b6;
    animation: spin 1s ease-in-out infinite;
}

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

/* Responsive for Upload Modal */
@media (max-width: 768px) {
    .upload-modal {
        width: 95%;
        margin: 10px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .modal-actions {
        flex-direction: column;
    }

    .modal-btn {
        width: 100%;
    }
}
