/**
 * Estilos públicos - Legal CRM
 */

.legal-crm-form,
.legal-crm-list,
.legal-crm-dashboard {
    max-width: 1200px;
    margin: 20px auto;
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Lista de casos: ocupar 90% del ancho disponible */
.legal-crm-list-cases {
    width: 90%;
    max-width: 90%;
    margin: 20px auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Lista de clientes: ocupar 90% del ancho disponible */
.legal-crm-list-clients {
    width: 90%;
    max-width: 90%;
    margin: 20px auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.legal-crm-form-wrapper {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.legal-crm-form-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.legal-crm-form-row label {
    font-weight: 600;
    color: #333;
}

.legal-crm-form-row input[type="text"],
.legal-crm-form-row input[type="email"],
.legal-crm-form-row input[type="date"],
.legal-crm-form-row input[type="file"],
.legal-crm-form-row select,
.legal-crm-form-row textarea {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    width: 100%;
    box-sizing: border-box;
}

.legal-crm-form-row textarea {
    resize: vertical;
    min-height: 100px;
}

.legal-crm-form-actions {
    margin-top: 10px;
}

.legal-crm-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    transition: all 0.3s ease;
}

.legal-crm-btn-primary {
    background: #0073aa;
    color: #fff;
}

.legal-crm-btn-primary:hover {
    background: #005a87;
}

.legal-crm-btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

.legal-crm-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    table-layout: auto;
    min-width: 100%;
}

/* Contenedor de tabla con scroll horizontal si es necesario */
.legal-crm-list-cases {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.legal-crm-list-cases .legal-crm-table {
    min-width: 1000px; /* Ancho mínimo para mantener legibilidad */
}

/* Tabla RAG: mismo estilo que lista de casos */
#legal-crm-rag-manager.legal-crm-list-cases {
    width: 90%;
    max-width: 90%;
    margin: 20px auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

#legal-crm-rag-manager .legal-crm-table {
    min-width: 800px; /* Ancho mínimo para mantener legibilidad */
}

.legal-crm-list-clients {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.legal-crm-list-clients .legal-crm-table {
    min-width: 800px; /* Ancho mínimo para mantener legibilidad */
}

.legal-crm-table th,
.legal-crm-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.legal-crm-table th {
    background: #f5f5f5;
    font-weight: 600;
}

.legal-crm-table tr:hover {
    background: #f9f9f9;
}

.legal-crm-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.legal-crm-dashboard-section {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 6px;
}

.legal-crm-dashboard-section h3 {
    margin-top: 0;
    color: #0073aa;
}

.legal-crm-info-box {
    background: #fff;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.legal-crm-info-box p {
    margin: 10px 0;
}

.legal-crm-case-status,
.legal-crm-priority {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: #fff;
}

/* Badges dinámicos con colores personalizados */
.legal-crm-case-status[style*="background-color"],
.legal-crm-priority[style*="background-color"] {
    text-transform: none;
}

.legal-crm-case-status.status-abierto {
    background: #4caf50;
    color: #fff;
}

.legal-crm-case-status.status-en-curso {
    background: #ff9800;
    color: #fff;
}

.legal-crm-case-status.status-cerrado {
    background: #9e9e9e;
    color: #fff;
}

.legal-crm-priority.priority-baja {
    background: #9e9e9e;
    color: #fff;
}

.legal-crm-priority.priority-media {
    background: #ff9800;
    color: #fff;
}

.legal-crm-priority.priority-alta {
    background: #f44336;
    color: #fff;
}

.legal-crm-case-list,
.legal-crm-document-list {
    list-style: none;
    padding: 0;
}

.legal-crm-case-list li,
.legal-crm-document-list li {
    padding: 10px;
    margin: 5px 0;
    background: #fff;
    border-radius: 4px;
    border: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.legal-crm-task-manager {
    margin-top: 20px;
}

.legal-crm-task-list ul {
    list-style: none;
    padding: 0;
    margin-top: 20px;
}

.legal-crm-task-item {
    background: #fff;
    padding: 15px;
    margin: 10px 0;
    border-radius: 4px;
    border-left: 4px solid #ddd;
}

.legal-crm-task-item.status-pendiente {
    border-left-color: #ff9800;
}

.legal-crm-task-item.status-en-progreso {
    border-left-color: #2196f3;
}

.legal-crm-task-item.status-completada {
    border-left-color: #4caf50;
}

.legal-crm-task-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.legal-crm-task-meta {
    display: flex;
    gap: 15px;
    margin-top: 10px;
    font-size: 12px;
    color: #666;
}

.legal-crm-message {
    margin-top: 15px;
    padding: 12px;
    border-radius: 4px;
    display: none;
}

.legal-crm-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

.legal-crm-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

/* Celdas de estado de tareas */
.legal-crm-task-state-cell {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}

.legal-crm-task-count-number {
    font-weight: 700;
    font-size: 16px;
}

.legal-crm-task-icon-emoji {
    font-size: 18px;
    line-height: 1;
}

/* Modal */
.legal-crm-modal {
    display: none;
    position: fixed !important;
    z-index: 999999 !important;
    left: 0 !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background-color: rgba(0, 0, 0, 0.5);
    box-sizing: border-box;
    margin: 0 !important;
    padding: 0 !important;
}

.legal-crm-modal[style*="display: flex"],
.legal-crm-modal.show {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2vh 0 !important;
    box-sizing: border-box;
}

.legal-crm-modal-content {
    background-color: #fff;
    margin: 0 auto !important;
    padding: 0;
    border: none;
    width: 80% !important;
    max-width: 80% !important;
    min-width: 1000px;
    height: 90vh !important;
    max-height: 90vh !important;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    position: relative;
    flex-shrink: 0;
    flex-grow: 0;
    align-self: center;
    left: auto !important;
    right: auto !important;
    transform: none !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

.legal-crm-modal-header {
    padding: 20px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.legal-crm-modal-header h2 {
    margin: 0;
}

.legal-crm-modal-close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.legal-crm-modal-close:hover {
    color: #000;
}

.legal-crm-modal-body {
    padding: 20px;
    overflow: hidden;
    flex: 1;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

/* Layout del Modal */
.legal-crm-modal-layout {
    display: grid;
    grid-template-columns: 30% 70%;
    gap: 15px;
    min-height: 0;
    height: 100%;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    flex: 1;
}

.legal-crm-modal-sidebar {
    background: #f9f9f9;
    border-radius: 4px;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    height: 100%;
    min-height: 0;
}

.legal-crm-modal-main {
    overflow-y: auto;
    overflow-x: hidden;
    height: 100%;
    min-height: 0;
}

.legal-crm-add-task-form {
    background: transparent;
    padding: 0;
}

.legal-crm-add-task-form h3 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #0073aa;
    font-size: 18px;
}

.legal-crm-form-field {
    margin-bottom: 15px;
}

.legal-crm-form-field label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
    font-size: 13px;
}

.legal-crm-form-field input[type="text"],
.legal-crm-form-field input[type="date"],
.legal-crm-form-field select,
.legal-crm-form-field textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}

.legal-crm-form-field input.legal-crm-datepicker {
    cursor: pointer;
    background-color: #fff;
}

.legal-crm-form-field input.legal-crm-datepicker:hover {
    border-color: #2196f3;
}

/* Estilos para el datepicker de jQuery UI dentro del modal */
#legal-crm-tasks-modal .ui-datepicker {
    z-index: 9999999 !important;
    font-size: 14px;
}

#legal-crm-tasks-modal .ui-datepicker-header {
    background: #2196f3;
    color: #fff;
    border: none;
}

#legal-crm-tasks-modal .ui-datepicker-title {
    color: #fff;
}

#legal-crm-tasks-modal .ui-datepicker-prev,
#legal-crm-tasks-modal .ui-datepicker-next {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
}

#legal-crm-tasks-modal .ui-datepicker-prev:hover,
#legal-crm-tasks-modal .ui-datepicker-next:hover {
    background: rgba(255, 255, 255, 0.3);
}

.legal-crm-form-field textarea {
    resize: vertical;
    min-height: 80px;
}

/* Kanban Board */
.legal-crm-kanban-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.legal-crm-kanban-column {
    min-width: 0;
    box-sizing: border-box;
    overflow: hidden;
}

.legal-crm-kanban-column {
    background: #f5f5f5;
    border-radius: 4px;
    min-height: 400px;
    display: flex;
    flex-direction: column;
}

.legal-crm-kanban-column-header {
    padding: 12px;
    font-weight: 600;
    text-align: center;
    border-radius: 4px 4px 0 0;
    box-sizing: border-box;
    word-wrap: break-word;
}

.legal-crm-kanban-column-body {
    flex: 1;
    padding: 10px;
    min-height: 300px;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
}

.legal-crm-kanban-column-body.drag-over {
    background-color: #e3f2fd;
    border: 2px dashed #2196f3;
}

/* Task Cards */
.legal-crm-task-card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 10px;
    cursor: move;
    transition: box-shadow 0.3s;
    box-sizing: border-box;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.legal-crm-task-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.legal-crm-task-card.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

.legal-crm-task-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.legal-crm-task-card-header strong {
    flex: 1;
    font-size: 14px;
}

.legal-crm-task-description {
    font-size: 12px;
    color: #666;
    margin: 8px 0;
    line-height: 1.4;
}

.legal-crm-task-card-footer {
    display: flex;
    gap: 10px;
    font-size: 11px;
    color: #999;
    margin-top: 8px;
}

.legal-crm-task-assigned,
.legal-crm-task-due {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Responsive */
@media (max-width: 768px) {
    .legal-crm-dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    /* En móviles, las listas ocupan 95% */
    .legal-crm-list-cases,
    .legal-crm-list-clients {
        width: 95%;
        max-width: 95%;
        margin: 10px auto;
    }

    .legal-crm-table {
        font-size: 12px;
    }

    .legal-crm-table th,
    .legal-crm-table td {
        padding: 8px;
    }

    .legal-crm-kanban-board {
        grid-template-columns: 1fr;
    }
}

.legal-crm-modal-actions {
    padding: 20px;
    border-top: 1px solid #ddd;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: #fff;
    flex-shrink: 0;
}

.legal-crm-modal-actions button {
    min-width: 120px;
}

/* Ajustes para pantallas medianas */
@media (max-width: 1400px) {
    .legal-crm-list-cases,
    .legal-crm-list-clients {
        width: 92%;
        max-width: 92%;
    }
}

@media (max-width: 1200px) {
    .legal-crm-list-cases,
    .legal-crm-list-clients {
        width: 95%;
        max-width: 95%;
    }
    
    .legal-crm-modal-layout {
        grid-template-columns: 1fr;
    }

    .legal-crm-modal-sidebar {
        max-height: 300px;
    }
}

@media (max-width: 1600px) {
    .legal-crm-modal[style*="display: flex"],
    .legal-crm-modal.show {
        padding: 2vh 5%;
    }
    
    .legal-crm-modal-content {
        width: 90% !important;
        max-width: 90% !important;
    }
}

@media (max-width: 1400px) {
    .legal-crm-modal-content {
        width: 95% !important;
        max-width: 95% !important;
    }
}

/* Layout de formulario de caso (2 columnas) */
.legal-crm-case-form-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 20px;
}

.legal-crm-case-form-column {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Layout de formulario de cliente (2 secciones) */
.legal-crm-client-form-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 20px;
}

.legal-crm-client-photo-section {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
    gap: 10px;
}

.legal-crm-client-photo-section h3 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 15px;
    color: #333;
    flex-shrink: 0;
}

.legal-crm-photo-upload-container {
    width: 100%;
}

.legal-crm-photo-upload-placeholder {
    width: 100%;
    min-height: 140px;
    max-height: 140px;
    border: 2px dashed #ddd;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f9f9f9;
    flex-shrink: 0;
}

.legal-crm-photo-upload-placeholder:hover {
    border-color: #0073aa;
    background: #f0f8ff;
}

.legal-crm-photo-upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    width: 100%;
    height: 100%;
    padding: 10px;
}

.legal-crm-photo-icon {
    font-size: 36px;
    margin-bottom: 6px;
}

.legal-crm-photo-text {
    color: #666;
    font-size: 12px;
}

.legal-crm-photo-preview {
    width: 100%;
    text-align: center;
}

.legal-crm-photo-preview img {
    max-width: 100%;
    max-height: 120px;
    border-radius: 8px;
    margin-bottom: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.legal-crm-photo-actions {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-shrink: 0;
}

.legal-crm-photo-actions button {
    padding: 6px 12px;
    font-size: 12px;
}

#legal-crm-crop-container {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 8px;
    background: #f9f9f9;
    max-height: 280px;
    overflow: hidden;
    margin-top: 8px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

#legal-crm-cropper-wrapper {
    position: relative;
    max-height: 200px;
    overflow: hidden;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 8px;
    flex-shrink: 0;
}

#legal-crm-cropper-image {
    display: block;
    max-width: 100%;
}

.legal-crm-crop-actions {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 6px;
}

.legal-crm-crop-actions button {
    padding: 6px 12px;
    font-size: 12px;
}

@media (max-width: 768px) {
    .legal-crm-case-form-layout,
    .legal-crm-client-form-layout {
        grid-template-columns: 1fr;
    }
    
    .legal-crm-modal-actions {
        flex-direction: column;
    }

    .legal-crm-modal-actions button {
        width: 100%;
    }

    .legal-crm-modal-content {
        width: 95%;
        min-width: 95%;
        max-width: 95%;
        margin: 0;
        max-height: 100vh;
        border-radius: 0;
    }
}

/* Modal de Documentos */
.legal-crm-documents-modal-content {
    width: 95%;
    max-width: 95%;
    min-width: 1200px;
    max-height: 90vh;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.legal-crm-documents-layout {
    display: grid;
    grid-template-columns: 30% 20% 50%;
    gap: 20px;
    padding: 20px;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

.legal-crm-documents-upload-section,
.legal-crm-documents-list-section,
.legal-crm-documents-preview-section {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.legal-crm-documents-upload-section h3,
.legal-crm-documents-list-section h3,
.legal-crm-documents-preview-section h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 15px;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #2196f3;
    padding-bottom: 6px;
    flex-shrink: 0;
}

.legal-crm-upload-document-form {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.legal-crm-upload-document-form form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-height: 0;
}

.legal-crm-upload-document-form .legal-crm-form-field {
    margin-bottom: 0;
    flex-shrink: 0;
}

.legal-crm-upload-document-form .legal-crm-form-field label {
    font-size: 12px;
    margin-bottom: 4px;
}

.legal-crm-upload-document-form .legal-crm-form-field input[type="text"],
.legal-crm-upload-document-form .legal-crm-form-field input[type="file"],
.legal-crm-upload-document-form .legal-crm-form-field select {
    padding: 6px 8px;
    font-size: 12px;
}

.legal-crm-upload-document-form .legal-crm-form-field textarea {
    padding: 6px 8px;
    font-size: 12px;
    resize: none;
    min-height: 50px;
    max-height: 60px;
    rows: 2;
}

.legal-crm-upload-document-form #legal-crm-upload-btn {
    padding: 8px 16px;
    font-size: 13px;
    margin-top: 4px;
    flex-shrink: 0;
}

.legal-crm-upload-document-form #legal-crm-upload-progress {
    margin-top: 6px;
    flex-shrink: 0;
}

.legal-crm-upload-document-form #legal-crm-new-category-field {
    margin-top: 6px;
}

.legal-crm-upload-document-form #legal-crm-new-category-field input {
    padding: 6px 8px;
    font-size: 12px;
}

.legal-crm-upload-document-form .legal-crm-file-name {
    font-size: 11px;
    margin-top: 4px;
    color: #666;
}

/* Área de drag and drop */
.legal-crm-drag-drop-area {
    width: 100%;
    min-height: 120px;
    border: 2px dashed #ddd;
    border-radius: 8px;
    background: #f9f9f9;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 15px;
    box-sizing: border-box;
}

.legal-crm-drag-drop-area:hover {
    border-color: #2196f3;
    background: #f0f8ff;
}

.legal-crm-drag-drop-area.drag-over {
    border-color: #2196f3;
    background: #e3f2fd;
    border-style: solid;
}

.legal-crm-drag-drop-content {
    text-align: center;
    pointer-events: none;
}

.legal-crm-drag-drop-icon {
    font-size: 36px;
    margin-bottom: 8px;
}

.legal-crm-drag-drop-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.legal-crm-drag-drop-text strong {
    font-size: 13px;
    color: #333;
}

.legal-crm-drag-drop-text span {
    font-size: 11px;
    color: #666;
}

/* Lista de archivos */
.legal-crm-files-list {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px;
    background: #fff;
}

.legal-crm-file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    margin-bottom: 4px;
    background: #f9f9f9;
    border-radius: 4px;
    font-size: 11px;
}

.legal-crm-file-item:last-child {
    margin-bottom: 0;
}

.legal-crm-file-item-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #333;
}

.legal-crm-file-item-status {
    margin-left: 8px;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 600;
}

.legal-crm-file-item-status.pending {
    background: #fff3cd;
    color: #856404;
}

.legal-crm-file-item-status.uploading {
    background: #cfe2ff;
    color: #084298;
}

.legal-crm-file-item-status.success {
    background: #d1e7dd;
    color: #0f5132;
}

.legal-crm-file-item-status.error {
    background: #f8d7da;
    color: #842029;
}

.legal-crm-file-item-progress {
    width: 100%;
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    margin-top: 4px;
    overflow: hidden;
}

.legal-crm-file-item-progress-fill {
    height: 100%;
    background: #2196f3;
    transition: width 0.3s ease;
    width: 0%;
}

.legal-crm-documents-list {
    overflow-y: auto;
    max-height: calc(90vh - 120px);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.legal-crm-document-item {
    display: flex;
    gap: 10px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    background: #fff;
}

.legal-crm-document-item:hover {
    background: #f5f5f5;
    border-color: #2196f3;
}

.legal-crm-document-item.active {
    background: #e3f2fd;
    border-color: #2196f3;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.2);
}

.legal-crm-document-thumbnail {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    border-radius: 4px;
    overflow: hidden;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.legal-crm-document-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.legal-crm-document-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.legal-crm-document-name-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legal-crm-document-type-icon {
    flex-shrink: 0;
    font-size: 16px;
    line-height: 1;
}

.legal-crm-document-name {
    flex: 1;
    font-weight: 600;
    font-size: 13px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.legal-crm-document-delete {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #999;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background 0.2s;
}

.legal-crm-document-delete:hover {
    color: #c62828;
    background: rgba(198, 40, 40, 0.08);
}

.legal-crm-document-delete:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.legal-crm-document-has-markdown {
    flex-shrink: 0;
    font-size: 14px;
    line-height: 1;
}

.legal-crm-document-description {
    font-size: 11px;
    color: #666;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.legal-crm-document-category {
    font-size: 10px;
    color: #2196f3;
    font-weight: 600;
    text-transform: uppercase;
}

.legal-crm-documents-preview {
    overflow-y: auto;
    max-height: calc(90vh - 120px);
    background: #f5f5f5;
    border-radius: 4px;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}

.legal-crm-file-name {
    display: block;
    font-size: 12px;
    color: #666;
    margin-top: 5px;
    font-style: italic;
}

.legal-crm-upload-progress {
    margin-top: 15px;
}

.legal-crm-progress-bar {
    width: 100%;
    height: 20px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 8px;
}

.legal-crm-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #2196f3, #42a5f5);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 10px;
    position: relative;
    overflow: hidden;
}

.legal-crm-progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: progress-shimmer 1.5s infinite;
}

@keyframes progress-shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.legal-crm-progress-text {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: #2196f3;
}

.legal-crm-new-category-field {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e0e0e0;
}

.legal-crm-new-category-field input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}


.legal-crm-preview-placeholder {
    text-align: center;
    color: #999;
    font-size: 14px;
    padding: 40px;
}

.legal-crm-documents-preview iframe,
.legal-crm-documents-preview img,
.legal-crm-documents-preview video,
.legal-crm-documents-preview audio {
    max-width: 100%;
    border-radius: 4px;
}

@media (max-width: 1400px) {
    .legal-crm-documents-layout {
        grid-template-columns: 25% 25% 50%;
    }
}

@media (max-width: 1200px) {
    .legal-crm-documents-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr;
    }
    
    .legal-crm-documents-upload-section,
    .legal-crm-documents-list-section {
        max-height: 300px;
    }
}

/* Estilos para Convertidor de Documentos */
.legal-crm-converter-file-item {
    transition: background-color 0.2s;
    border-bottom: 1px solid #e5e5e5;
}

.legal-crm-converter-file-item:last-child {
    border-bottom: none;
}

.legal-crm-converter-file-item:hover {
    background: #e3f2fd !important;
}

.legal-crm-converter-delete-col:hover {
    opacity: 1 !important;
}

.legal-crm-converter-file-item.selected {
    background: #bbdefb !important;
}

.legal-crm-converter-files-list {
    scrollbar-width: thin;
    scrollbar-color: #ccc #f5f5f5;
}

.legal-crm-converter-files-list::-webkit-scrollbar {
    width: 6px;
}

.legal-crm-converter-files-list::-webkit-scrollbar-track {
    background: #f5f5f5;
}

.legal-crm-converter-files-list::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.legal-crm-converter-files-list::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.legal-crm-converter-viewer {
    scrollbar-width: thin;
    scrollbar-color: #ccc #f9f9f9;
}

.legal-crm-converter-viewer::-webkit-scrollbar {
    width: 8px;
}

.legal-crm-converter-viewer::-webkit-scrollbar-track {
    background: #f9f9f9;
}

.legal-crm-converter-viewer::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.legal-crm-converter-viewer::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* ============================================
   CHAT RAG - Estilos
   ============================================ */

#legal-crm-chat-modal .legal-crm-modal-content {
    display: flex;
    flex-direction: column;
}

#legal-crm-chat-messages {
    scrollbar-width: thin;
    scrollbar-color: #ccc #fafafa;
}

#legal-crm-chat-messages::-webkit-scrollbar {
    width: 8px;
}

#legal-crm-chat-messages::-webkit-scrollbar-track {
    background: #fafafa;
}

#legal-crm-chat-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

#legal-crm-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.legal-crm-chat-message {
    word-wrap: break-word;
    animation: fadeIn 0.3s ease-in;
}

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

.legal-crm-chat-user {
    text-align: right;
}

.legal-crm-chat-assistant {
    text-align: left;
}

/* Cortina desplegable de fuentes consultadas (Chat con IA) */
.legal-crm-chat-sources summary::-webkit-details-marker {
    display: none;
}
.legal-crm-chat-sources summary::marker {
    display: none;
    content: none;
}
.legal-crm-chat-sources[open] summary span:first-child {
    transform: rotate(90deg);
}

#legal-crm-chat-question:focus {
    outline: none;
    border-color: #2196f3;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

#legal-crm-chat-send:hover {
    background: #1976d2;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#legal-crm-chat-process-docs:hover {
    background: #f5f5f5;
}

#legal-crm-chat-filter-types {
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    min-height: 80px;
    max-height: 120px;
}

#legal-crm-chat-filter-types option {
    padding: 5px;
}

#legal-crm-chat-case-types-filter {
    padding: 8px;
    background: #f9f9f9;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

/* ============================================
   GESTIÓN DE JURISPRUDENCIA RAG (FRONTEND)
   ============================================ */

.legal-crm-rag-manager {
    max-width: 1400px;
    margin: 20px auto;
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.legal-crm-rag-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

.legal-crm-rag-header h2 {
    margin: 0 0 10px 0;
    color: #333;
}

.legal-crm-rag-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 6px;
}

.legal-crm-rag-filter {
    display: flex;
    align-items: center;
    gap: 10px;
}

.legal-crm-rag-filter label {
    font-weight: 600;
    color: #333;
}

.legal-crm-rag-folders-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.legal-crm-rag-folder-card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.legal-crm-rag-folder-card:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.legal-crm-rag-folder-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e0e0e0;
}

.legal-crm-rag-folder-header h3 {
    margin: 0;
    color: #2196f3;
    font-size: 18px;
}

.legal-crm-rag-folder-actions {
    display: flex;
    gap: 8px;
}

.legal-crm-rag-folder-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.legal-crm-rag-folder-path {
    font-size: 12px;
    color: #666;
}

.legal-crm-rag-folder-path code {
    background: #f5f5f5;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    word-break: break-all;
}

.legal-crm-rag-folder-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 13px;
}

.legal-crm-rag-stat {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legal-crm-rag-stat strong {
    color: #333;
    min-width: 100px;
}

.legal-crm-rag-empty {
    text-align: center;
    padding: 60px 20px;
    color: #999;
    grid-column: 1 / -1;
}

.legal-crm-rag-status-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Footer del modal RAG */
#legal-crm-rag-folder-modal .legal-crm-modal-footer {
    position: absolute;
    bottom: 0;
    right: 0;
    padding: 15px 20px;
    background: #f9f9f9;
    border-top: 1px solid #ddd;
    width: 100%;
    box-sizing: border-box;
    text-align: right;
    z-index: 10;
    border-radius: 0 0 8px 8px;
}

/* Ajustar body del modal para que no se solape con el footer */
#legal-crm-rag-folder-modal .legal-crm-modal-content {
    position: relative;
    padding-bottom: 0;
}

#legal-crm-rag-folder-modal .legal-crm-modal-body {
    padding-bottom: 70px; /* Espacio para el footer */
    max-height: calc(100% - 140px); /* Altura total menos header y footer */
    overflow-y: auto;
}

.legal-crm-rag-status-info {
    padding: 15px;
    background: #f9f9f9;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.legal-crm-rag-status-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #e0e0e0;
}

.legal-crm-rag-status-item:last-child {
    border-bottom: none;
}

.legal-crm-rag-status-item strong {
    color: #333;
}

.legal-crm-rag-actions {
    margin-top: 10px;
}

.legal-crm-rag-processing-status {
    padding: 15px;
    background: #e3f2fd;
    border-radius: 6px;
    border: 1px solid #2196f3;
}

.legal-crm-document-item {
    transition: background 0.2s ease;
}

.legal-crm-document-item:hover {
    background: #f5f5f5;
}

.legal-crm-document-item.selected {
    background: #e3f2fd;
    border-left: 3px solid #2196f3;
}

/* Responsive */
@media (max-width: 768px) {
    .legal-crm-rag-folders-list {
        grid-template-columns: 1fr;
    }
    
    .legal-crm-rag-controls {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .legal-crm-rag-folder-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .legal-crm-rag-folder-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

/* Ajustes para columna "Ver" - reducir fuente y evitar scroll */
#legal-crm-rag-files-list-container {
    font-size: 11px !important;
    max-height: calc(100vh - 400px);
    overflow-y: auto;
    overflow-x: hidden;
}

#legal-crm-rag-files-list-container .legal-crm-document-item {
    font-size: 11px !important;
    padding: 6px 8px !important;
    line-height: 1.4 !important;
}

#legal-crm-rag-files-list-container .legal-crm-document-item div {
    font-size: 11px !important;
}

/* Ajustes para tabla de Estado y Acciones - redimensionar para verse completa */
.legal-crm-rag-status-section {
    max-height: calc(100vh - 300px);
    overflow-y: auto;
    overflow-x: hidden;
}

.legal-crm-rag-status-info {
    font-size: 12px;
    margin-bottom: 15px;
    padding: 10px !important;
}

.legal-crm-rag-status-item {
    padding: 6px 0 !important;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px !important;
}

