/* ==========================================================================
   Modals CSS - Estilos de modales generales y CRM
   ========================================================================== */

/* Modal de resumen (genérico) */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 900px;
    width: 90%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

.modal-header {
    padding: 25px 30px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px 12px 0 0;
}

.modal-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

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

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

.modal-body {
    padding: 30px;
    overflow-y: auto;
    flex: 1;
}

.modal-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 30px;
    gap: 20px;
}

.modal-loading .spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Resumen content */
.resumen-content {
    line-height: 1.8;
    color: var(--color-gray-800);
}

.resumen-content h1,
.resumen-content h2,
.resumen-content h3 {
    margin-top: 24px;
    margin-bottom: 12px;
    color: var(--color-primary);
}

.resumen-content h1 {
    font-size: 24px;
    border-bottom: 2px solid var(--color-primary);
    padding-bottom: 8px;
}

.resumen-content h2 {
    font-size: 20px;
}

.resumen-content h3 {
    font-size: 18px;
}

.resumen-content ul,
.resumen-content ol {
    margin-left: 20px;
    margin-bottom: 16px;
}

.resumen-content li {
    margin-bottom: 8px;
}

.resumen-content strong {
    color: var(--color-primary);
    font-weight: 600;
}

.resumen-content p {
    margin-bottom: 12px;
}

/* =====================================================
   MODALES CRM
   ===================================================== */

.crm-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.2s ease;
}

.crm-modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

.crm-modal-content.crm-modal-large {
    max-width: 750px;
}

/* Pestañas del modal */
.crm-modal-tabs {
    display: flex;
    border-bottom: 1px solid #e0e0e0;
    padding: 0 24px;
    background: #fafafa;
}

.crm-modal-tab {
    padding: 14px 24px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-gray-600);
    position: relative;
    transition: all 0.2s;
}

.crm-modal-tab:hover {
    color: var(--color-brand);
}

.crm-modal-tab.active {
    color: var(--color-brand);
}

.crm-modal-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--color-brand);
    border-radius: 3px 3px 0 0;
}

.crm-tab-content {
    display: none;
}

.crm-tab-content.active {
    display: block;
}

/* Estilos para propiedades de cuenta */
.crm-properties-intro {
    background: var(--color-gray-100);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.crm-properties-intro p {
    margin: 0;
    color: var(--color-gray-600);
    font-size: 14px;
}

.crm-form-help {
    display: block;
    font-size: 12px;
    color: #888;
    margin-top: 5px;
}

.crm-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px 0;
}

.crm-checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 8px 12px;
    background: var(--color-gray-100);
    border-radius: 6px;
    transition: background 0.2s;
}

.crm-checkbox-item:hover {
    background: #f0f0f0;
}

.crm-checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.crm-checkbox-item span {
    font-size: 14px;
    color: var(--color-gray-800);
}

/* CRM Modal Header */
.crm-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
}

.crm-modal-header h2 {
    margin: 0;
    font-size: 20px;
    color: var(--color-gray-800);
}

.crm-modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: #f0f0f0;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.crm-modal-close:hover {
    background: #e0e0e0;
    transform: scale(1.1);
}

/* CRM Form */
.crm-modal form {
    padding: 24px;
}

.crm-form-group {
    margin-bottom: 18px;
}

.crm-form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--color-gray-800);
    font-size: 14px;
}

.crm-form-group input,
.crm-form-group select,
.crm-form-group textarea {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s, box-shadow 0.3s;
    box-sizing: border-box;
}

.crm-form-group input:focus,
.crm-form-group select:focus,
.crm-form-group textarea:focus {
    border-color: var(--color-brand);
    outline: none;
    box-shadow: 0 0 0 3px rgba(221, 72, 50, 0.1);
}

.crm-form-group input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
}

.crm-form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

@media (max-width: 600px) {
    .crm-form-row {
        grid-template-columns: 1fr;
    }
}

/* CRM Modal Footer */
.crm-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid #eee;
    background: var(--color-gray-100);
    border-radius: 0 0 12px 12px;
    position: sticky;
    bottom: 0;
}

/* Pipeline Manager */
.crm-pipeline-manager {
    padding: 24px;
}

.crm-pipeline-list {
    margin-bottom: 24px;
}

.crm-pipeline-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: var(--color-gray-100);
    border-radius: 8px;
    margin-bottom: 10px;
}

.crm-pipeline-item.default {
    border-left: 4px solid var(--color-brand);
}

.crm-pipeline-item-name {
    font-weight: 600;
    color: var(--color-gray-800);
}

.crm-pipeline-item-actions {
    display: flex;
    gap: 8px;
}

.crm-stage-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.crm-stage-probability {
    font-size: 12px;
    color: var(--color-gray-600);
}

.crm-pipeline-form {
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.crm-pipeline-form h4 {
    margin: 0 0 16px 0;
    color: var(--color-gray-800);
}

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

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