/* Estilos específicos para la página de Clientes (clientes.html) */

/* Botón de sucursales */
.btn-branches {
    background: linear-gradient(135deg, #10b981, #059669) !important;
    color: white !important;
    border: none !important;
    transition: all 0.2s ease !important;
    font-weight: 500 !important;
}

.btn-branches:hover {
    background: linear-gradient(135deg, #059669, #047857) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3) !important;
}

/* Estilos para sucursales */
.branch-card {
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    padding: 20px;
    margin-bottom: 16px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.branch-card:hover {
    border-color: #10b981;
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.15);
}

.branch-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.branch-title {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.branch-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
    display: flex;
    align-items: center;
}

.branch-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.branch-address {
    color: #6b7280;
    font-size: 0.9rem;
    margin: 8px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.branch-address i {
    color: #8b5cf6;
}

.branch-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid #f3f4f6;
    font-size: 0.9rem;
    color: #6b7280;
}

.branch-details div {
    display: flex;
    align-items: center;
    gap: 8px;
}

.branch-details i {
    width: 16px;
    color: #8b5cf6;
}

.branch-notes {
    background: #f8fafc;
    padding: 8px 12px;
    border-radius: 6px;
    border-left: 3px solid #8b5cf6;
    margin-top: 4px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #9ca3af;
}

.empty-state i {
    display: block;
    margin-bottom: 16px;
}

.empty-state p {
    margin: 8px 0;
}

/* Estilos específicos del cliente modal */
#client-modal .modal-content {
    max-width: 900px;
}

#client-modal .form-group {
    margin-bottom: 30px;
}

/* Sección del formulario */
.form-section {
    background: #f8fafc;
    border-radius: 8px;
    padding: 28px;
    margin: 30px 0;
    border-left: 4px solid var(--primary-color);
}

.form-section-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-section-title::before {
    content: "📍";
    font-size: 1.2rem;
}

/* Estilos específicos para contactos */
.contact-title::before {
    content: "👤";
}

.form-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.contact-item {
    background: #ffffff;
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 20px;
    border: 1px solid #e2e8f0;
    position: relative;
}

.contact-item:last-child {
    margin-bottom: 0;
}

.contact-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e2e8f0;
}

.contact-number {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 1rem;
}

.btn-remove-contact {
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fecaca;
    padding: 8px 14px;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-remove-contact:hover {
    background: #fecaca;
    border-color: #f87171;
}

.btn-small {
    padding: 10px 16px;
    font-size: 1rem;
}

/* Estilos para información de contacto en la tabla */
.contact-info {
    font-size: 1rem;
}

.contact-name {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.contact-details {
    font-size: 0.85rem;
    color: var(--text-light);
}

.contact-email {
    color: var(--primary-color);
    text-decoration: none;
    display: block;
    margin-bottom: 2px;
}

.contact-email:hover {
    text-decoration: underline;
}

.contact-phone {
    color: var(--text-light);
    font-size: 0.8rem;
}

.text-muted {
    color: var(--text-light);
    font-style: italic;
}

/* Estilos para ver cliente */
.client-view-sections {
    max-height: 70vh;
    overflow-y: auto;
    padding-right: 10px;
}

.view-section {
    margin-bottom: 30px;
    padding: 20px;
    background: #f8fafc;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-item label {
    font-weight: 600;
    color: var(--text-light);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-item span {
    color: var(--text-dark);
    font-weight: 500;
}

/* Estilos para contactos en vista */
.contacts-list {
    display: grid;
    gap: 16px;
}

.contact-card {
    background: white;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.contact-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e2e8f0;
}

.contact-position {
    color: var(--primary-color);
    font-size: 0.9rem;
    font-weight: 500;
}

.contact-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 8px;
    margin-bottom: 8px;
}

.contact-details div {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-dark);
}

.contact-details i {
    color: var(--primary-color);
    width: 16px;
}

.contact-notes {
    background: #f1f5f9;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.9rem;
    color: var(--text-dark);
    margin-top: 8px;
}

/* Estilos para sucursales */
.branch-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
}

.branch-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.branch-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.branch-address {
    color: var(--text-light);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.branch-actions {
    display: flex;
    gap: 8px;
}

.branch-details {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 0.9rem;
}

.branch-details div {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-dark);
}

.branch-details i {
    color: var(--primary-color);
    width: 16px;
}

/* Estilos para sucursales en vista */
.branch-card-view {
    background: white;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    margin-bottom: 12px;
}

.branch-card-view .branch-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.branch-card-view .branch-address {
    color: var(--text-light);
    margin-bottom: 8px;
}

.branch-card-view .branch-details {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.85rem;
}

.branch-card-view .branch-details span {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-dark);
}

/* Estado vacío */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
}

.empty-state i {
    display: block;
    margin-bottom: 16px;
}

/* Estilos responsivos */
@media (max-width: 768px) {
    .info-grid {
        grid-template-columns: 1fr;
    }
    
    .branch-header {
        flex-direction: column;
        gap: 12px;
    }
    
    .branch-details {
        flex-direction: column;
        gap: 8px;
    }
}

/* Filas del formulario */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 16px;
}

.form-row:last-child {
    margin-bottom: 0;
}

/* Select personalizado */
.form-select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
}

.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Validación de RUT */
#client-rut {
    font-family: monospace;
}

#client-rut.valid {
    border-color: var(--tertiary-color);
    background: #f0fdf4;
}

#client-rut.invalid {
    border-color: var(--danger-color);
    background: #fef2f2;
}

/* Estilos para la tabla de clientes */
#clients-table .client-name {
    font-weight: 600;
    color: var(--text-dark);
}

#clients-table .client-company {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 2px;
}

#clients-table .client-email {
    color: var(--primary-color);
    text-decoration: none;
}

#clients-table .client-email:hover {
    text-decoration: underline;
}

#clients-table .client-phone {
    font-family: monospace;
    background: #f1f5f9;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.9rem;
}

#clients-table .client-rut {
    font-family: monospace;
    font-weight: 500;
    color: var(--text-dark);
}

#clients-table .client-date {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Estados de clientes */
.client-status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.client-status.active {
    background: #d1fae5;
    color: #065f46;
}

.client-status.inactive {
    background: #fee2e2;
    color: #991b1b;
}

/* Filtros adicionales para clientes */
.client-filters {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    align-items: center;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-group label {
    font-size: 0.85rem;
    color: var(--text-light);
    font-weight: 500;
}

.filter-select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    min-width: 120px;
}

/* Responsive para clientes */
@media (max-width: 768px) {
    #client-modal .modal-content {
        max-width: 95%;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .form-section {
        padding: 16px;
        margin: 16px 0;
    }
    
    .client-filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .filter-select {
        min-width: auto;
        width: 100%;
    }
    
    #clients-table .client-company,
    #clients-table .client-date {
        display: none;
    }
    
    #clients-table th:nth-child(4),
    #clients-table td:nth-child(4),
    #clients-table th:nth-child(5),
    #clients-table td:nth-child(5) {
        display: none;
    }
}

/* Botones de acción optimizados */
.action-buttons {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
}

.btn-action {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 12px;
}

.btn-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.btn-view {
    background-color: #17a2b8;
    color: white;
}

.btn-view:hover {
    background-color: #138496;
}

.btn-edit {
    background-color: #007bff;
    color: white;
}

.btn-edit:hover {
    background-color: #0056b3;
}

.btn-copy {
    background-color: #6c757d;
    color: white;
}

.btn-copy:hover {
    background-color: #545b62;
}

.btn-delete {
    background-color: #dc3545;
    color: white;
}

.btn-delete:hover {
    background-color: #c82333;
}

/* Responsive para botones */
@media (max-width: 768px) {
    .action-buttons {
        gap: 2px;
    }
    
    .btn-action {
        width: 24px;
        height: 24px;
        font-size: 10px;
    }
}

/* Botón de sincronización de contactos */
.btn-sync {
    background: linear-gradient(135deg, #17a2b8, #138496);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.btn-sync:hover {
    background: linear-gradient(135deg, #138496, #117a8b);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(23, 162, 184, 0.3);
}

.btn-sync:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(23, 162, 184, 0.3);
}

.btn-sync.syncing {
    background: linear-gradient(135deg, #6c757d, #5a6268);
    cursor: not-allowed;
    pointer-events: none;
}

.btn-sync.syncing i {
    animation: spin 1s linear infinite;
}

.btn-sync.success {
    background: linear-gradient(135deg, #28a745, #218838);
}

.btn-sync.success::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shine 1.5s ease-out;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes shine {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Responsive para botón de sync */
@media (max-width: 768px) {
    .btn-sync {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
    
    .btn-sync span {
        display: none;
    }
}

/* Estilos para detalles del cliente */
.client-details {
    padding: 20px;
}

.detail-group {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 3px solid var(--primary-color);
}

.detail-group h4 {
    color: var(--primary-color);
    font-size: 1.1rem;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-group p {
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.detail-group strong {
    color: #495057;
    min-width: 140px;
    display: inline-block;
}

.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.bg-success {
    background-color: #28a745;
    color: white;
}

.bg-warning {
    background-color: #ffc107;
    color: #212529;
}

/* ===== MODAL DE CONTACTO ===== */
#add-contact-modal .modal-content {
    max-width: 600px;
}

.checkbox-container {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 10px 0;
}

.checkbox-custom {
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-radius: 4px;
    position: relative;
    transition: all 0.2s ease;
}

.checkbox-container input[type="checkbox"] {
    display: none;
}

.checkbox-container input[type="checkbox"]:checked + .checkbox-custom {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.checkbox-container input[type="checkbox"]:checked + .checkbox-custom::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: bold;
    font-size: 14px;
}

.checkbox-label {
    font-weight: 500;
    color: var(--text-dark);
    user-select: none;
}

.checkbox-container:hover .checkbox-custom {
    border-color: var(--primary-color);
}

/* Estilos para el contenedor de contactos */
#contacts-container {
    min-height: 50px;
    padding: 10px 0;
}

#contacts-container:empty::after {
    content: "No hay contactos agregados. Haz clic en 'Agregar Contacto' para comenzar.";
    display: block;
    text-align: center;
    color: #6c757d;
    font-style: italic;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px dashed #dee2e6;
}

/* Mensaje cuando no hay contactos */
.no-contacts-message {
    text-align: center;
    padding: 30px 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px dashed #dee2e6;
    color: #6c757d;
}

.no-contacts-message i {
    font-size: 2rem;
    margin-bottom: 10px;
    opacity: 0.7;
}

.no-contacts-message p {
    margin: 10px 0 5px 0;
    font-weight: 500;
}

.no-contacts-message small {
    opacity: 0.8;
}

/* Estilos para items de contacto en el modal */
.contact-item {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 12px;
    transition: all 0.2s ease;
}

.contact-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.contact-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.contact-info h5.contact-name {
    margin: 0 0 5px 0;
    color: var(--text-dark);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.contact-position {
    margin: 0;
    color: #6c757d;
    font-size: 0.9rem;
    font-style: italic;
}

.primary-badge {
    background: var(--primary-color);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.contact-actions {
    display: flex;
    gap: 5px;
}

.btn-icon {
    padding: 6px 8px;
    border: none;
    border-radius: 4px;
    background: #f8f9fa;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.85rem;
}

.btn-icon:hover {
    background: var(--primary-color);
    color: white;
}

.btn-icon.btn-danger:hover {
    background: var(--danger-color);
    color: white;
}

.contact-details {
    padding-top: 10px;
    border-top: 1px solid #f1f3f4;
}

.contact-details p {
    margin: 5px 0;
    font-size: 0.9rem;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 8px;
}

.contact-details i {
    width: 16px;
    color: var(--primary-color);
    font-size: 0.8rem;
}

/* Estilos para botones de contacto */
.contact-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.form-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

/* Responsive para botones de contacto */
@media (max-width: 768px) {
    .form-section-header {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    
    .contact-buttons {
        justify-content: center;
    }
    
    .contact-header {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    
    .contact-actions {
        justify-content: center;
    }
}

/* === FORMULARIO INLINE DE CONTACTO === */

.inline-contact-form {
    background: #f0f9ff;
    border: 2px solid #0ea5e9;
    border-radius: 12px;
    padding: 0;
    margin-top: 20px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.15);
    transition: all 0.3s ease;
}

.inline-contact-form:hover {
    box-shadow: 0 6px 20px rgba(14, 165, 233, 0.2);
}

.contact-form-header {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    color: white;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0;
}

.contact-form-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.contact-form-title i {
    font-size: 1.1rem;
    opacity: 0.9;
}

.btn-close-inline {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

.btn-close-inline:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.btn-close-inline i {
    font-size: 14px;
}

.contact-form-content {
    padding: 24px;
    background: white;
}

.contact-form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
}

.contact-form-actions .btn {
    min-width: 120px;
}

.contact-form-actions .btn-primary {
    background: #0ea5e9;
    border-color: #0ea5e9;
}

.contact-form-actions .btn-primary:hover {
    background: #0284c7;
    border-color: #0284c7;
    transform: translateY(-1px);
}

.contact-form-actions .btn-outline:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

/* Animación de aparición del formulario */
.inline-contact-form[style*="display: block"] {
    animation: slideInDown 0.3s ease-out;
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
        max-height: 0;
    }
    to {
        opacity: 1;
        transform: translateY(0);
        max-height: 500px;
    }
}

/* Estilos para los campos del formulario inline */
.inline-contact-form .form-row {
    margin-bottom: 16px;
}

.inline-contact-form .form-group {
    margin-bottom: 0;
}

.inline-contact-form .form-input,
.inline-contact-form .form-textarea {
    border-color: #cbd5e1;
    transition: all 0.2s ease;
}

.inline-contact-form .form-input:focus,
.inline-contact-form .form-textarea:focus {
    border-color: #0ea5e9;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.inline-contact-form .checkbox-container {
    background: #f8fafc;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    margin: 8px 0;
}

.inline-contact-form .form-hint {
    color: #64748b;
    font-size: 0.85rem;
    margin-top: 4px;
}

/* Responsive para formulario inline */
@media (max-width: 768px) {
    .contact-form-content {
        padding: 16px;
    }
    
    .contact-form-header {
        padding: 12px 16px;
    }
    
    .contact-form-title {
        font-size: 0.9rem;
    }
    
    .contact-form-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .contact-form-actions .btn {
        min-width: auto;
    }
    
    .inline-contact-form .form-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

/* === INDICADOR DE CARGA === */

.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-container p {
    margin: 0;
    color: #6b7280;
    font-size: 0.9rem;
    font-style: italic;
}

/* Optimización de rendimiento para la tabla */
#clients-tbody {
    /* Habilitar aceleración por hardware */
    transform: translateZ(0);
    will-change: contents;
}

.action-buttons {
    /* Optimizar botones de acción */
    contain: layout;
}

/* Reducir repaints en hover */
.btn-action {
    will-change: background-color, transform;
}

/* === ANIMACIONES PARA ACTUALIZACIONES DINÁMICAS === */

/* Animación de entrada para nuevos clientes */
@keyframes slideInFromTop {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Animación de salida para clientes eliminados */
@keyframes slideOutToLeft {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-30px);
    }
}

/* Animación de actualización para clientes editados */
@keyframes highlightUpdate {
    0% {
        background-color: #e8f5e8;
        transform: scale(1);
    }
    50% {
        background-color: #d4edda;
        transform: scale(1.01);
    }
    100% {
        background-color: transparent;
        transform: scale(1);
    }
}

/* Clases para las animaciones */
.client-row-enter {
    animation: slideInFromTop 0.3s ease-out;
}

.client-row-exit {
    animation: slideOutToLeft 0.3s ease-in;
}

.client-row-update {
    animation: highlightUpdate 0.6s ease-in-out;
}

/* Transiciones suaves para todos los cambios en la tabla */
#clients-tbody tr {
    transition: all 0.3s ease;
}

#clients-tbody tr:hover {
    background-color: #f8fafc;
    transform: translateX(2px);
}

/* Optimización de rendimiento adicional */
.action-buttons button {
    transition: all 0.2s ease;
    backface-visibility: hidden;
}

.action-buttons button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* === ESTILOS PARA VALIDACIÓN DE FORMULARIOS === */

.form-input.error,
.form-textarea.error,
.form-select.error {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
    background-color: #fef2f2;
}

.form-input.error:focus,
.form-textarea.error:focus,
.form-select.error:focus {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2) !important;
}

.error-message {
    color: #ef4444;
    font-size: 0.8rem;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.error-message i {
    font-size: 0.7rem;
}

/* Animación para campos con error */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.form-input.error {
    animation: shake 0.5s ease-in-out;
}

/* ========== ESTILOS PARA CONTACTO CLICKEABLE Y MODAL RÁPIDO ========== */

/* Estilos del contacto clickeable en la tabla */
.contact-name {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.contact-clickable {
    cursor: pointer;
    color: #3b82f6;
    text-decoration: none;
    border-radius: 4px;
    padding: 2px 6px;
    transition: all 0.2s ease;
    position: relative;
}

.contact-clickable:hover {
    background-color: rgba(59, 130, 246, 0.1);
    color: #1d4ed8;
    transform: translateY(-1px);
    text-decoration: underline;
}

.contact-clickable:active {
    transform: translateY(0);
}

/* Modal rápido de cliente */
.quick-modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    position: relative;
    animation: quickModalSlideIn 0.3s ease-out;
}

@keyframes quickModalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.quick-modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.quick-modal-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.3) 100%);
}

.client-quick-info h3 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.client-quick-info h3 i {
    background: rgba(255, 255, 255, 0.25);
    padding: 8px;
    border-radius: 50%;
    font-size: 1rem;
}

.client-quick-rut {
    font-size: 0.9rem;
    opacity: 0.9;
    font-family: monospace;
    background: rgba(255, 255, 255, 0.15);
    padding: 4px 8px;
    border-radius: 4px;
    margin-top: 5px;
    display: inline-block;
}

.quick-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.quick-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.quick-modal-body {
    padding: 25px;
    max-height: calc(80vh - 100px);
    overflow-y: auto;
}

.quick-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.quick-info-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 15px;
    background: #f8fafc;
    border-radius: 8px;
    border-left: 4px solid #e2e8f0;
    transition: all 0.2s ease;
}

.quick-info-item:hover {
    background: #f1f5f9;
    border-left-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.quick-info-item i {
    color: #667eea;
    font-size: 1.2rem;
    margin-top: 2px;
    min-width: 20px;
}

.quick-info-item div {
    flex: 1;
}

.quick-info-item strong {
    display: block;
    color: #374151;
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 0.9rem;
}

.quick-info-item span {
    display: block;
    color: #6b7280;
    font-size: 0.95rem;
    line-height: 1.4;
}

.quick-info-item small {
    display: block;
    color: #9ca3af;
    font-size: 0.8rem;
    margin-top: 2px;
}

.quick-contacts-section {
    margin-top: 25px;
    border-top: 1px solid #e5e7eb;
    padding-top: 20px;
}

.quick-contacts-section h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 15px 0;
    color: #374151;
    font-size: 1.1rem;
    font-weight: 600;
}

.quick-contacts-section h4 i {
    color: #667eea;
}

.quick-contacts-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.quick-contact-item {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    transition: all 0.2s ease;
}

.quick-contact-item.primary {
    background: linear-gradient(135deg, #dbeafe 0%, #e0f2fe 100%);
    border-color: #3b82f6;
    position: relative;
}

.quick-contact-item.primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    border-radius: 4px 0 0 4px;
}

.quick-contact-item:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.quick-contact-item.primary:hover {
    background: linear-gradient(135deg, #bfdbfe 0%, #bae6fd 100%);
}

.quick-contact-name {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
    font-size: 1rem;
}

.primary-badge {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.quick-contact-position {
    color: #6b7280;
    font-style: italic;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.quick-contact-details {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    font-size: 0.85rem;
}

.quick-contact-details span {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #6b7280;
}

.quick-contact-details i {
    color: #9ca3af;
    font-size: 0.8rem;
    min-width: 12px;
}

.quick-actions {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 12px;
    justify-content: center;
}

.quick-actions .btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.quick-actions .btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
}

.quick-actions .btn-primary:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.quick-actions .btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

.quick-actions .btn-secondary:hover {
    background: #e5e7eb;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Responsive para modal rápido */
@media (max-width: 768px) {
    .quick-modal-content {
        width: 95%;
        max-height: 90vh;
        margin: 20px;
    }
    
    .quick-modal-header {
        padding: 15px 20px;
    }
    
    .client-quick-info h3 {
        font-size: 1.1rem;
    }
    
    .quick-modal-body {
        padding: 20px;
    }
    
    .quick-info-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .quick-actions {
        flex-direction: column;
    }
    
    .quick-actions .btn {
        justify-content: center;
    }
}

/* ========================================
   ESTILOS PARA MODO EDICIÓN DE CLIENTE
   ======================================== */

/* Modal en modo edición - Cambio de color para diferenciarlo */
#client-modal.editing-mode .modal-content {
    border: 3px solid #ff6b35;
    box-shadow: 0 15px 35px rgba(255, 107, 53, 0.3);
    animation: editingPulse 2s ease-in-out infinite alternate;
}

/* Animación sutil para el modo edición */
@keyframes editingPulse {
    0% {
        box-shadow: 0 15px 35px rgba(255, 107, 53, 0.3);
    }
    100% {
        box-shadow: 0 15px 35px rgba(255, 107, 53, 0.5);
    }
}

/* Header del modal en modo edición */
#client-modal.editing-mode .modal-header {
    background: linear-gradient(135deg, #ff6b35, #f7931e);
    color: white;
    position: relative;
    overflow: hidden;
}

/* Icono de edición en el título */
#client-modal.editing-mode .modal-title::before {
    content: "✏️ ";
    font-size: 1.2em;
    margin-right: 8px;
}

/* Badge de modo edición */
.editing-badge {
    position: absolute;
    top: 10px;
    right: 60px;
    background: rgba(255, 255, 255, 0.9);
    color: #ff6b35;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
    opacity: 0;
    animation: fadeInBadge 0.5s ease-in-out 0.3s forwards;
}

@keyframes fadeInBadge {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Botón principal en modo edición */
#client-modal.editing-mode .btn-primary:not(.btn-small) {
    background: linear-gradient(135deg, #ff6b35, #f7931e);
    border-color: #ff6b35;
    position: relative;
    overflow: hidden;
}

#client-modal.editing-mode .btn-primary:not(.btn-small):hover {
    background: linear-gradient(135deg, #e55a2b, #e0821a);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 107, 53, 0.4);
}

/* Icono dinámico en el botón */
.btn-submit-icon {
    margin-right: 8px;
    transition: all 0.3s ease;
}

/* Modo creación - Mantener estilos originales pero mejorados */
#client-modal:not(.editing-mode) .modal-header {
    background: linear-gradient(135deg, var(--primary-color), #4f46e5);
    color: white;
}

#client-modal:not(.editing-mode) .modal-title::before {
    content: "➕ ";
    font-size: 1.2em;
    margin-right: 8px;
}

/* Badge de modo creación */
.creating-badge {
    position: absolute;
    top: 10px;
    right: 60px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--primary-color);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    display: none !important; /* Forzar que esté oculto */
    align-items: center;
    gap: 5px;
    opacity: 0;
    animation: fadeInBadge 0.5s ease-in-out 0.3s forwards;
}

/* Efectos de transición suaves */
#client-modal .modal-content,
#client-modal .modal-header,
#client-modal .btn-primary {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Mejoras visuales adicionales */
#client-modal.editing-mode .form-section {
    border-left-color: #ff6b35;
    background: rgba(255, 107, 53, 0.02);
}

#client-modal.editing-mode .form-section-title {
    color: #d63384;
}

/* Estilo para campos requeridos en modo edición */
#client-modal.editing-mode .form-input:required:valid {
    border-left: 4px solid #28a745;
}

#client-modal.editing-mode .form-input:required:invalid {
    border-left: 4px solid #dc3545;
}

/* Indicador de campos modificados */
.field-modified {
    position: relative;
}

.field-modified::after {
    content: "●";
    position: absolute;
    right: -15px;
    top: 50%;
    transform: translateY(-50%);
    color: #ff6b35;
    font-size: 1.2em;
    animation: modifiedPulse 1.5s ease-in-out infinite;
}

@keyframes modifiedPulse {
    0%, 100% {
        opacity: 0.6;
        transform: translateY(-50%) scale(1);
    }
    50% {
        opacity: 1;
        transform: translateY(-50%) scale(1.1);
    }
}

/* Estilos para contactos clickables */
.contact-name {
    font-weight: 500;
    color: #333;
    transition: all 0.2s ease;
}

.contact-name.contact-clickable {
    color: #007bff;
    cursor: pointer;
    border-bottom: 1px dotted transparent;
    padding: 2px 4px;
    border-radius: 3px;
    text-decoration: none;
    position: relative;
}

.contact-name.contact-clickable:hover {
    color: #0056b3;
    background-color: rgba(0, 123, 255, 0.1);
    border-bottom-color: #007bff;
    transform: translateY(-1px);
}

.contact-name.contact-clickable:active {
    transform: translateY(0);
    background-color: rgba(0, 123, 255, 0.2);
}

/* Icono indicativo de contacto clickable */
.contact-name.contact-clickable::after {
    content: "👤";
    font-size: 0.8em;
    margin-left: 5px;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.contact-name.contact-clickable:hover::after {
    opacity: 1;
}

/* Estilo para cuando no hay contacto */
.contact-name:not(.contact-clickable) {
    color: #6c757d;
    font-style: italic;
}

/* Animación sutil para contactos recién creados */
@keyframes contactCreated {
    0% {
        background-color: rgba(40, 167, 69, 0.3);
        transform: scale(1.05);
    }
    100% {
        background-color: transparent;
        transform: scale(1);
    }
}

.contact-name.contact-newly-created {
    animation: contactCreated 1s ease-out;
}

/* Animación para sincronización automática */
@keyframes autoSyncSuccess {
    0% {
        background-color: rgba(0, 123, 255, 0.2);
        box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.5);
    }
    50% {
        background-color: rgba(40, 167, 69, 0.2);
        box-shadow: 0 0 0 10px rgba(40, 167, 69, 0);
    }
    100% {
        background-color: transparent;
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0);
    }
}

.contact-name.auto-synced {
    animation: autoSyncSuccess 1.5s ease-out;
    border-radius: 4px;
    padding: 2px 6px;
}

/* Efecto visual para tabla actualizada */
@keyframes tableRowHighlight {
    0% {
        background-color: rgba(0, 123, 255, 0.1);
    }
    100% {
        background-color: transparent;
    }
}

.client-row-updated {
    animation: tableRowHighlight 1s ease-out;
}

/* Modal de reasignación de contacto principal */
.reassign-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 15000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.3s ease;
}

.reassign-modal-overlay.show {
    opacity: 1;
}

.reassign-modal-content {
    background: white;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s ease;
}

.reassign-modal-overlay.show .reassign-modal-content {
    transform: scale(1) translateY(0);
}

.reassign-modal-header {
    background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
    color: white;
    padding: 24px;
    border-radius: 16px 16px 0 0;
    position: relative;
}

.reassign-modal-header h3 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

.reassign-modal-close {
    position: absolute;
    top: 20px;
    right: 24px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.reassign-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.reassign-modal-body {
    padding: 24px;
}

.warning-message {
    background: #fff5f5;
    border: 1px solid #fed7d7;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.warning-icon {
    color: #e53e3e;
    font-size: 20px;
    margin-top: 2px;
}

.warning-text {
    flex: 1;
    color: #742a2a;
    font-size: 0.95rem;
    line-height: 1.4;
}

.contact-selection-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.contact-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.contact-option {
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
}

.contact-option:hover {
    border-color: #667eea;
    background: #f7fafc;
}

.contact-option.selected {
    border-color: #667eea;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(255, 255, 255, 0.8) 100%);
}

.contact-option-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.contact-radio {
    width: 18px;
    height: 18px;
    border: 2px solid #cbd5e0;
    border-radius: 50%;
    position: relative;
    transition: all 0.2s ease;
}

.contact-option.selected .contact-radio {
    border-color: #667eea;
}

.contact-option.selected .contact-radio::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
}

.contact-name {
    font-weight: 600;
    color: #2d3748;
    font-size: 1rem;
}

.contact-position {
    color: #718096;
    font-size: 0.9rem;
    font-style: italic;
    margin-bottom: 8px;
}

.contact-details {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 0.85rem;
    color: #4a5568;
}

.contact-detail {
    display: flex;
    align-items: center;
    gap: 6px;
}

.no-principal-option {
    border-color: #fed7d7 !important;
    background: #fffaf0;
}

.no-principal-option:hover {
    border-color: #fc8181 !important;
    background: #fff5f5;
}

.no-principal-option.selected {
    border-color: #e53e3e !important;
    background: linear-gradient(135deg, rgba(229, 62, 62, 0.1) 0%, rgba(255, 255, 255, 0.8) 100%);
}

.reassign-modal-actions {
    padding: 20px 24px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.reassign-btn {
    padding: 12px 24px;
    border-radius: 8px;
    border: none;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.reassign-btn-primary {
    background: #667eea;
    color: white;
}

.reassign-btn-primary:hover {
    background: #5a67d8;
}

.reassign-btn-secondary {
    background: transparent;
    color: #718096;
    border: 2px solid #e2e8f0;
}

.reassign-btn-secondary:hover {
    background: #f7fafc;
    border-color: #cbd5e0;
}

/* ====================================
   OCULTAR BOTÓN DUPLICAR
   ==================================== */

/* Ocultar botón duplicar en lista y tabla de clientes */
.btn-copy {
    display: none !important;
}

/* Ocultar botón duplicar en modal de detalles del cliente */
button[onclick*="duplicarCliente"] {
    display: none !important;
}

/* ====================================
   MODAL EDITAR CONTACTO MEJORADO
   ==================================== */

/* Modal específico para editar contacto */
#editContactModal.modal {
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

#editContactModal .modal-content {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    max-width: 550px;
    width: 90%;
    max-height: 85vh;
    overflow: hidden;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

#editContactModal .modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 30px;
    border-bottom: none;
    position: relative;
}

#editContactModal .modal-header h2 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

#editContactModal .modal-header .close {
    color: white;
    font-size: 28px;
    font-weight: 300;
    opacity: 0.8;
    transition: all 0.2s ease;
    padding: 5px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#editContactModal .modal-header .close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

#editContactModal .modal-body {
    padding: 30px;
    background: #fafbfc;
}

#editContactModal .form-group {
    margin-bottom: 20px;
}

#editContactModal .form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #374151;
    font-size: 14px;
}

#editContactModal .form-group input[type="text"],
#editContactModal .form-group input[type="email"],
#editContactModal .form-group input[type="tel"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.2s ease;
    background: white;
    box-sizing: border-box;
}

#editContactModal .form-group input[type="text"]:focus,
#editContactModal .form-group input[type="email"]:focus,
#editContactModal .form-group input[type="tel"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

#editContactModal .form-group input[type="text"]:invalid,
#editContactModal .form-group input[type="email"]:invalid {
    border-color: #ef4444;
}

/* Checkbox mejorado para contacto principal */
#editContactModal .form-group label:has(input[type="checkbox"]) {
    display: flex;
    align-items: center;
    cursor: pointer;
    background: white;
    padding: 12px 16px;
    border-radius: 10px;
    border: 2px solid #e5e7eb;
    transition: all 0.2s ease;
    margin-bottom: 0;
}

#editContactModal .form-group label:has(input[type="checkbox"]):hover {
    border-color: #667eea;
    background: #f8faff;
}

#editContactModal .form-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 10px;
    accent-color: #667eea;
}

/* Botones mejorados */
#editContactModal .form-actions {
    margin-top: 30px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
}

#editContactModal .form-actions button {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

#editContactModal .form-actions button[type="button"] {
    background: #6b7280;
    color: white;
}

#editContactModal .form-actions button[type="button"]:hover {
    background: #4b5563;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(107, 114, 128, 0.3);
}

#editContactModal .form-actions button[type="submit"] {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    min-width: 150px;
}

#editContactModal .form-actions button[type="submit"]:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

#editContactModal .form-actions button[type="submit"]:active {
    transform: translateY(0);
}

/* Responsive para modal */
@media (max-width: 768px) {
    #editContactModal .modal-content {
        width: 95%;
        max-height: 90vh;
        margin: 20px 0;
    }
    
    #editContactModal .modal-header,
    #editContactModal .modal-body {
        padding: 20px;
    }
    
    #editContactModal .form-actions {
        flex-direction: column-reverse;
    }
    
    #editContactModal .form-actions button {
        width: 100%;
    }
}

/* ====================================
   MODAL EXPORTAR CLIENTES MEJORADO
   ==================================== */

/* Modal específico para exportar clientes */
#export-options-modal.modal {
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

#export-options-modal .modal-content {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    max-width: 520px;
    width: 90%;
    max-height: 85vh;
    overflow: hidden;
    animation: modalSlideIn 0.3s ease-out;
}

#export-options-modal .modal-header {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 20px 30px;
    border-bottom: none;
    position: relative;
}

#export-options-modal .modal-header h3 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

#export-options-modal .modal-header .modal-close {
    color: white;
    font-size: 28px;
    font-weight: 300;
    opacity: 0.8;
    transition: all 0.2s ease;
    padding: 5px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
}

#export-options-modal .modal-header .modal-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

#export-options-modal .modal-body {
    padding: 30px;
    background: #fafbfc;
}

#export-options-modal .modal-body p {
    margin: 0 0 20px 0;
    color: #374151;
    font-weight: 500;
}

/* Botones de exportación mejorados */
#export-options-modal .modal-body > div:first-of-type {
    display: grid !important;
    gap: 12px !important;
    margin: 20px 0 !important;
}

#export-options-modal .btn {
    padding: 16px 20px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    border: 2px solid transparent;
    text-align: left;
    position: relative;
    overflow: hidden;
}

#export-options-modal .btn i {
    font-size: 18px;
    width: 20px;
}

#export-options-modal .btn-primary {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: white;
    border-color: #059669;
}

#export-options-modal .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(5, 150, 105, 0.3);
}

#export-options-modal .btn-outline {
    background: white;
    color: #374151;
    border-color: #d1d5db;
}

#export-options-modal .btn-outline:hover {
    background: #f9fafb;
    border-color: #059669;
    color: #059669;
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(5, 150, 105, 0.1);
}

/* Sección de información mejorada */
#export-options-modal .modal-body > div:last-of-type {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%) !important;
    padding: 20px !important;
    border-radius: 12px !important;
    margin-top: 25px !important;
    border: 1px solid #bae6fd;
}

#export-options-modal .modal-body h4 {
    margin: 0 0 15px 0 !important;
    color: #0c4a6e !important;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

#export-options-modal .modal-body ul {
    margin: 0 !important;
    padding-left: 20px !important;
    color: #0369a1 !important;
}

#export-options-modal .modal-body li {
    margin-bottom: 6px;
    font-size: 14px;
}

/* Footer del modal mejorado */
#export-options-modal .modal-footer {
    padding: 20px 30px;
    border-top: 1px solid #e5e7eb;
    background: white;
    display: flex;
    justify-content: center;
}

#export-options-modal .modal-footer .btn-secondary {
    background: #6b7280;
    color: white;
    padding: 10px 24px;
    border-radius: 10px;
    font-weight: 600;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

#export-options-modal .modal-footer .btn-secondary:hover {
    background: #4b5563;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(107, 114, 128, 0.3);
}

/* Responsive para modal de exportación */
@media (max-width: 768px) {
    #export-options-modal .modal-content {
        width: 95%;
        max-height: 90vh;
        margin: 20px 0;
    }
    
    #export-options-modal .modal-header,
    #export-options-modal .modal-body,
    #export-options-modal .modal-footer {
        padding: 20px;
    }
    
    #export-options-modal .btn {
        padding: 14px 16px;
        font-size: 14px;
    }
}

/* ===== ESTILOS MODAL SUCURSALES PREMIUM ===== */

/* Modal principal */
.branch-modal-content {
    max-width: 750px !important;
    width: 95% !important;
    max-height: 95vh !important;
    border-radius: 16px !important;
    overflow: hidden !important;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25) !important;
    animation: modalSlideIn 0.3s ease-out !important;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Header del modal */
.branch-modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    padding: 1.25rem 1.5rem !important;
    border: none !important;
    position: relative !important;
}

.branch-modal-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, rgba(255,255,255,0.1) 0%, transparent 100%);
    pointer-events: none;
}

.branch-modal-header .modal-title {
    color: white !important;
    font-size: 1.3rem !important;
    font-weight: 600 !important;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2) !important;
}

.branch-modal-header .modal-close {
    color: white !important;
    background: rgba(255,255,255,0.2) !important;
    border: 1px solid rgba(255,255,255,0.3) !important;
    border-radius: 8px !important;
    padding: 0.5rem !important;
    transition: all 0.2s ease !important;
}

.branch-modal-header .modal-close:hover {
    background: rgba(255,255,255,0.3) !important;
    transform: scale(1.05) !important;
}

/* Body del modal */
.branch-modal-body {
    padding: 2rem !important;
    max-height: calc(95vh - 160px) !important;
    overflow-y: auto !important;
    background: #fafbfc !important;
}

/* Secciones del formulario */
.form-section {
    background: white !important;
    border-radius: 12px !important;
    padding: 1.5rem !important;
    margin-bottom: 1.5rem !important;
    border: 1px solid #e1e5e9 !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06) !important;
    transition: all 0.2s ease !important;
}

.form-section:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.1) !important;
    border-color: #d0d7de !important;
}

.form-section:last-child {
    margin-bottom: 0 !important;
}

/* Headers de sección */
.form-section-header {
    display: flex !important;
    align-items: center !important;
    margin-bottom: 1.5rem !important;
    padding-bottom: 0.75rem !important;
    border-bottom: 2px solid #f0f2f5 !important;
}

.section-icon {
    width: 40px !important;
    height: 40px !important;
    border-radius: 10px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin-right: 12px !important;
    font-size: 1.1rem !important;
    color: white !important;
}

.branch-section-basic .section-icon {
    background: linear-gradient(135deg, #667eea, #764ba2) !important;
}

.branch-section-location .section-icon {
    background: linear-gradient(135deg, #f093fb, #f5576c) !important;
}

.branch-section-contact .section-icon {
    background: linear-gradient(135deg, #4facfe, #00f2fe) !important;
}

.branch-section-notes .section-icon {
    background: linear-gradient(135deg, #43e97b, #38f9d7) !important;
}

.form-section-title {
    font-size: 1.1rem !important;
    font-weight: 600 !important;
    color: #2d3748 !important;
    margin: 0 !important;
    letter-spacing: -0.025em !important;
}

/* Labels con iconos coloridos */
.form-label {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    font-weight: 500 !important;
    color: #374151 !important;
    margin-bottom: 0.5rem !important;
    font-size: 0.9rem !important;
}

.form-label i {
    width: 16px !important;
    font-size: 0.9rem !important;
}

.text-primary { color: #667eea !important; }
.text-info { color: #17a2b8 !important; }
.text-success { color: #28a745 !important; }
.text-warning { color: #ffc107 !important; }
.text-danger { color: #dc3545 !important; }
.text-secondary { color: #6c757d !important; }

/* Form rows mejorados */
.form-row {
    display: flex !important;
    gap: 1.25rem !important;
    margin-bottom: 0 !important;
}

.form-row .form-group {
    flex: 1 !important;
    margin-bottom: 1.25rem !important;
}

.form-group-address {
    flex: 2.5 !important;
}

/* Campos de formulario mejorados */
.form-input,
.form-select {
    width: 100% !important;
    padding: 0.75rem 1rem !important;
    border: 2px solid #e2e8f0 !important;
    border-radius: 8px !important;
    font-size: 0.9rem !important;
    transition: all 0.2s ease !important;
    background-color: white !important;
    font-family: inherit !important;
}

.form-input:focus,
.form-select:focus {
    outline: none !important;
    border-color: #667eea !important;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1) !important;
    transform: translateY(-1px) !important;
}

.form-textarea {
    resize: vertical !important;
    min-height: 100px !important;
    line-height: 1.5 !important;
}

/* Select mejorado */
.form-select {
    cursor: pointer !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e") !important;
    background-position: right 0.75rem center !important;
    background-repeat: no-repeat !important;
    background-size: 1.25rem !important;
    appearance: none !important;
}

/* Footer del modal */
.branch-modal-footer {
    background: linear-gradient(to right, #f8f9fa, #ffffff) !important;
    padding: 1.25rem 2rem !important;
    border-top: 1px solid #e9ecef !important;
}

.modal-actions {
    display: flex !important;
    gap: 1rem !important;
    justify-content: flex-end !important;
    align-items: center !important;
}

/* Botones mejorados */
.btn {
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 0.75rem 1.5rem !important;
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    border-radius: 8px !important;
    border: none !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    text-decoration: none !important;
    position: relative !important;
    overflow: hidden !important;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3) !important;
}

.btn-primary:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4) !important;
}

.btn-cancel {
    background: white !important;
    color: #6b7280 !important;
    border: 2px solid #e5e7eb !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05) !important;
}

.btn-cancel:hover {
    background: #f9fafb !important;
    border-color: #d1d5db !important;
    transform: translateY(-1px) !important;
}

/* Responsive mejorado */
@media (max-width: 768px) {
    .branch-modal-content {
        width: 98% !important;
        max-width: none !important;
        margin: 1rem !important;
    }
    
    .branch-modal-body {
        padding: 1.25rem !important;
    }
    
    .form-row {
        flex-direction: column !important;
        gap: 0 !important;
    }
    
    .form-section {
        padding: 1rem !important;
        margin-bottom: 1rem !important;
    }
    
    .modal-actions {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }
    
    .btn {
        width: 100% !important;
        justify-content: center !important;
    }
    
    .section-icon {
        width: 36px !important;
        height: 36px !important;
        font-size: 1rem !important;
    }
}

/* Scrollbar personalizado para el modal */
.branch-modal-body::-webkit-scrollbar {
    width: 6px;
}

.branch-modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.branch-modal-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.branch-modal-body::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}
