/**
 * Estilos actualizados para la integración con Odoo - Simplificado solo búsqueda por nombre
 * assets/css/odoo.css
 */

/* Contenedor principal de Odoo */
.odoo-integration-column {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-left: 12px;
    border-left: 1px solid var(--border);
    min-height: 500px;
    max-width: 350px;
}

/* Estado de conexión Odoo */
.odoo-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg-light);
    border-radius: 6px;
    border: 1px solid var(--border);
    font-size: 12px;
    font-weight: 600;
    transition: var(--transition);
}

.odoo-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #cbd5e0;
    transition: var(--transition);
}

/* Estados de conexión */
.odoo-status.disconnected .odoo-status-dot {
    background: #e53e3e;
}

.odoo-status.connecting .odoo-status-dot {
    background: #ed8936;
    animation: pulse 1.5s infinite;
}

.odoo-status.connected .odoo-status-dot {
    background: #38a169;
}

.odoo-status.error .odoo-status-dot {
    background: #e53e3e;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.1); }
}

/* Formulario de conexión mejorado */
.odoo-connection-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #ffffff;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.odoo-connection-form .field {
    margin-bottom: 0;
}

.odoo-connection-form .label {
    display: block;
    margin-bottom: 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.odoo-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 12px;
    color: var(--text-primary);
    background: #ffffff;
    transition: var(--transition);
    font-family: inherit;
}

.odoo-input:focus {
    outline: none;
    border-color: #714b67;
    box-shadow: 0 0 0 3px rgba(113, 75, 103, 0.1);
    background: #fefefe;
}

.odoo-input:disabled {
    background: var(--bg-light);
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.7;
}

.odoo-input[type="url"] {
    font-family: monospace;
    font-size: 11px;
}

.odoo-input[type="password"] {
    letter-spacing: 2px;
}

/* Botón de Odoo mejorado */
.btn-odoo {
    background: linear-gradient(135deg, #714b67 0%, #8b5a6b 100%);
    color: #ffffff;
    border: 1px solid #714b67;
    font-weight: 600;
    width: 100%;
    justify-content: center;
    padding: 10px 12px;
    font-size: 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(113, 75, 103, 0.2);
}

.btn-odoo:hover:not(:disabled) {
    background: linear-gradient(135deg, #5a3a52 0%, #6d4a56 100%);
    border-color: #5a3a52;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(113, 75, 103, 0.3);
}

.btn-odoo:disabled {
    background: #cbd5e0;
    border-color: #cbd5e0;
    color: #a0aec0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-odoo.connecting {
    background: linear-gradient(135deg, #ed8936 0%, #f6ad55 100%);
    border-color: #ed8936;
    animation: connectingGlow 2s infinite;
}

.btn-odoo.connected {
    background: linear-gradient(135deg, #38a169 0%, #48bb78 100%);
    border-color: #38a169;
}

@keyframes connectingGlow {
    0%, 100% { box-shadow: 0 2px 4px rgba(237, 137, 54, 0.2); }
    50% { box-shadow: 0 4px 12px rgba(237, 137, 54, 0.4); }
}

/* Información de conexión mejorada */
.odoo-info {
    background: linear-gradient(135deg, #f0fff4 0%, #ffffff 100%);
    border: 1px solid #9ae6b4;
    border-radius: 8px;
    padding: 14px;
    box-shadow: 0 1px 3px rgba(56, 161, 105, 0.1);
}

.odoo-info .field {
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(154, 230, 180, 0.3);
}

.odoo-info .field:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.odoo-info .label {
    font-size: 10px;
    font-weight: 600;
    color: #2f855a;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 3px;
}

.odoo-info .value {
    font-size: 12px;
    color: var(--text-primary);
    font-weight: 500;
    word-break: break-word;
}

/* ===== ESTILOS PARA TICKETS - SIMPLIFICADOS ===== */

/* Sección de tickets */
.tickets-section {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin-top: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Header de tickets */
.tickets-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.tickets-header .label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin: 0;
}

.tickets-controls {
    display: flex;
    gap: 6px;
}

/* Búsqueda simplificada de tickets */
.tickets-search-simple {
    margin-bottom: 12px;
    padding: 10px;
    background: var(--bg-light);
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.search-field .label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 6px;
    display: block;
}

.search-info {
    margin-top: 6px;
}

.search-info small {
    color: #718096;
    font-size: 10px;
    line-height: 1.3;
    display: block;
}

/* Lista de tickets */
.tickets-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #ffffff;
}

.no-tickets, .tickets-empty {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    padding: 20px;
    font-size: 12px;
}

.ticket-item {
    padding: 10px 12px;
    border-bottom: 1px solid #f1f3f4;
    transition: all 0.2s ease;
    cursor: pointer;
    font-size: 12px;
    position: relative;
}

.ticket-item:last-child {
    border-bottom: none;
}

.ticket-item:hover {
    background: var(--bg-light);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.ticket-item.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Header del ticket */
.ticket-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
    gap: 8px;
}

.ticket-title {
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    flex: 1;
    word-break: break-word;
}

.ticket-id {
    font-size: 10px;
    color: var(--text-muted);
    background: var(--bg-light);
    padding: 2px 6px;
    border-radius: 3px;
    white-space: nowrap;
    font-family: monospace;
}

/* Información del ticket */
.ticket-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ticket-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: 10px;
    color: var(--text-secondary);
}

.ticket-status {
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 9px;
    letter-spacing: 0.5px;
}

.ticket-status.open,
.ticket-status.new {
    background: #e6f3ff;
    color: #0066cc;
}

.ticket-status.in-progress,
.ticket-status.assigned {
    background: #fff3cd;
    color: #856404;
}

.ticket-status.resolved,
.ticket-status.done,
.ticket-status.closed {
    background: #d4edda;
    color: #155724;
}

.ticket-status.cancelled,
.ticket-status.rejected {
    background: #f8d7da;
    color: #721c24;
}

.ticket-priority {
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 600;
    font-size: 9px;
    text-transform: uppercase;
}

.ticket-priority.low {
    background: #e8f5e8;
    color: #2e7d32;
}

.ticket-priority.normal {
    background: #e3f2fd;
    color: #1976d2;
}

.ticket-priority.high {
    background: #fff3e0;
    color: #f57c00;
}

.ticket-priority.urgent {
    background: #ffebee;
    color: #d32f2f;
}

.ticket-date {
    font-size: 10px;
    color: var(--text-muted);
    font-family: monospace;
}

.ticket-description {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-top: 4px;
    max-height: 40px;
    overflow: hidden;
    position: relative;
}

.ticket-description.expanded {
    max-height: none;
}

.ticket-customer {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.ticket-customer-icon {
    font-size: 10px;
}

/* Acciones del ticket */
.ticket-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.ticket-item:hover .ticket-actions {
    opacity: 1;
}

.ticket-action-btn {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.ticket-action-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Estadísticas de tickets */
.tickets-stats {
    display: flex;
    justify-content: space-between;
    margin-top: 12px;
    padding: 8px 12px;
    background: var(--bg-light);
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.stats-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.stats-label {
    font-size: 9px;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.stats-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Estados de carga para tickets */
.tickets-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 12px;
}

.tickets-loading::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid #e9ecef;
    border-top: 2px solid #714b67;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

.tickets-error {
    padding: 12px;
    background: #fed7d7;
    color: #9b2c2c;
    border-radius: 6px;
    font-size: 11px;
    border: 1px solid #feb2b2;
    text-align: center;
}

/* Acciones de Odoo mejoradas */
.odoo-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.btn-small {
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.btn-success {
    background: linear-gradient(135deg, #38a169 0%, #48bb78 100%);
    color: #ffffff;
    border: 1px solid #38a169;
    box-shadow: 0 1px 3px rgba(56, 161, 105, 0.2);
}

.btn-success:hover {
    background: linear-gradient(135deg, #2f855a 0%, #38a169 100%);
    border-color: #2f855a;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(56, 161, 105, 0.3);
}

.btn-info {
    background: linear-gradient(135deg, #4299e1 0%, #63b3ed 100%);
    color: #ffffff;
    border: 1px solid #4299e1;
    box-shadow: 0 1px 3px rgba(66, 153, 225, 0.2);
}

.btn-info:hover {
    background: linear-gradient(135deg, #3182ce 0%, #4299e1 100%);
    border-color: #3182ce;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(66, 153, 225, 0.3);
}

.btn-secondary {
    background: linear-gradient(135deg, #718096 0%, #a0aec0 100%);
    color: #ffffff;
    border: 1px solid #718096;
    box-shadow: 0 1px 3px rgba(113, 128, 150, 0.2);
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #4a5568 0%, #718096 100%);
    border-color: #4a5568;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(113, 128, 150, 0.3);
}

/* Log de actividad mejorado */
.odoo-log {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding-top: 12px;
    flex-grow: 1;
    min-height: 120px;
}

.odoo-log .label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 6px;
}

.log-content {
    max-height: 160px;
    overflow-y: auto;
    background: #f8f9fa;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 10px;
    font-size: 10px;
    font-family: 'Courier New', monospace;
    line-height: 1.4;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

.log-entry {
    margin-bottom: 4px;
    color: var(--text-secondary);
    word-wrap: break-word;
    padding: 2px 0;
    border-bottom: 1px solid rgba(226, 232, 240, 0.5);
}

.log-entry:last-child {
    margin-bottom: 0;
    border-bottom: none;
}

.log-entry.success {
    color: #38a169;
    font-weight: 500;
}

.log-entry.error {
    color: #e53e3e;
    font-weight: 500;
}

.log-entry.info {
    color: #4299e1;
}

.log-entry.warning {
    color: #ed8936;
    font-weight: 500;
}

/* Scrollbar personalizado para el log y tickets */
.log-content::-webkit-scrollbar,
.tickets-list::-webkit-scrollbar {
    width: 4px;
}

.log-content::-webkit-scrollbar-track,
.tickets-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 2px;
}

.log-content::-webkit-scrollbar-thumb,
.tickets-list::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 2px;
}

.log-content::-webkit-scrollbar-thumb:hover,
.tickets-list::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Estados visuales del contenedor */
.odoo-integration-column.connected {
    background: linear-gradient(to bottom, #f0fff4 0%, #ffffff 100%);
    border-left-color: #38a169;
}

.odoo-integration-column.error {
    background: linear-gradient(to bottom, #fed7d7 0%, #ffffff 100%);
    border-left-color: #e53e3e;
}

/* Animaciones de estado */
.odoo-status.connecting {
    animation: connectingPulse 2s infinite;
}

@keyframes connectingPulse {
    0%, 100% {
        background: var(--bg-light);
        border-color: var(--border);
    }
    50% {
        background: #fff3cd;
        border-color: #ffc107;
    }
}

/* Notificaciones toast mejoradas */
.odoo-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    z-index: 1000;
    animation: slideInRight 0.3s ease-out;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    min-width: 250px;
    max-width: 400px;
}

.odoo-notification.success {
    background: linear-gradient(135deg, #38a169 0%, #48bb78 100%);
    color: #ffffff;
}

.odoo-notification.error {
    background: linear-gradient(135deg, #e53e3e 0%, #fc8181 100%);
    color: #ffffff;
}

.odoo-notification.info {
    background: linear-gradient(135deg, #4299e1 0%, #63b3ed 100%);
    color: #ffffff;
}

.odoo-notification.warning {
    background: linear-gradient(135deg, #ed8936 0%, #f6ad55 100%);
    color: #ffffff;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Header del toggle para Odoo */
.odoo-header-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 10px 12px;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 6px;
    transition: all 0.2s ease;
    user-select: none;
}

.odoo-header-toggle:hover {
    background: #e2e8f0;
    border-color: #cbd5e0;
}

.odoo-header-toggle .column-header {
    margin: 0;
    padding: 0;
    border: none;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Icono del toggle */
.toggle-icon {
    font-size: 12px;
    color: var(--text-secondary);
    transition: transform 0.3s ease;
    font-weight: bold;
}

.toggle-icon.expanded {
    transform: rotate(180deg);
}

/* Contenido colapsable */
.odoo-content {
    max-height: 800px;
    overflow: hidden;
    transition: all 0.4s ease;
    opacity: 1;
    padding-top: 16px;
}

.odoo-content.collapsed {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
    border: none;
    transition: all 0.4s ease;
}

/* Ajuste del contenedor principal cuando está colapsado */
.odoo-integration-column.collapsed {
    min-height: auto;
    margin-bottom: 16px;
}

/* Animación suave para el contenido */
.odoo-content > * {
    transition: opacity 0.2s ease;
}

.odoo-content.collapsed > * {
    opacity: 0;
}

/* Estados hover mejorados para el toggle */
.odoo-header-toggle:active {
    transform: scale(0.98);
}

/* Responsive para Odoo y Tickets */
@media (max-width: 1200px) {
    .odoo-integration-column {
        max-width: 320px;
        gap: 12px;
    }
    
    .odoo-connection-form {
        padding: 12px;
        gap: 10px;
    }
    
    .log-content {
        max-height: 120px;
        font-size: 9px;
    }
    
    .tickets-list {
        max-height: 250px;
    }
    
    .ticket-item {
        padding: 8px 10px;
    }
}

@media (max-width: 1024px) {
    .odoo-integration-column {
        border-left: none;
        border-top: 1px solid var(--border);
        padding-left: 0;
        padding-top: 16px;
        margin-top: 16px;
        max-width: none;
    }
    
    .tickets-controls {
        flex-direction: column;
        gap: 4px;
    }
}

@media (max-width: 768px) {
    .odoo-actions {
        flex-direction: row;
        justify-content: space-between;
        gap: 6px;
    }
    
    .btn-small {
        flex: 1;
        padding: 8px 6px;
        font-size: 10px;
    }
    
    .log-content {
        max-height: 100px;
        font-size: 9px;
    }
    
    .odoo-connection-form {
        padding: 10px;
        gap: 8px;
    }
    
    .odoo-input {
        padding: 6px 8px;
        font-size: 11px;
    }
    
    .odoo-notification {
        top: 10px;
        right: 10px;
        left: 10px;
        min-width: auto;
        max-width: none;
    }
    
    .odoo-header-toggle {
        padding: 8px 10px;
    }
    
    .toggle-icon {
        font-size: 12px;
        color: var(--text-secondary);
        transition: transform 0.3s ease;
        font-weight: bold;
    }
    
    .tickets-section {
        padding: 12px;
    }
    
    .tickets-list {
        max-height: 200px;
    }
    
    .ticket-item {
        padding: 6px 8px;
        font-size: 11px;
    }
    
    .tickets-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .tickets-controls {
        flex-direction: row;
        gap: 6px;
        width: 100%;
    }
    
    .tickets-stats {
        padding: 6px 8px;
    }
    
    .stats-value {
        font-size: 12px;
    }
}

/* Efectos hover mejorados */
.odoo-input:hover:not(:disabled) {
    border-color: #714b67;
    background: #fafafa;
}

.odoo-status:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

.odoo-info:hover {
    box-shadow: 0 2px 6px rgba(56, 161, 105, 0.15);
}

/* Indicadores de carga */
.odoo-loading {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #f3f3f3;
    border-radius: 50%;
    border-top: 2px solid #714b67;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Estados de campos */
.odoo-input.error {
    border-color: #e53e3e;
    background: #fed7d7;
}

.odoo-input.success {
    border-color: #38a169;
    background: #f0fff4;
}

/* Tooltip simple */
.odoo-tooltip {
    position: relative;
}

.odoo-tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
}

/* Animaciones para tickets */
.ticket-item {
    animation: ticketSlideIn 0.3s ease-out;
}

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

/* Estados especiales para tickets */
.ticket-item.priority-urgent {
    border-left: 3px solid #d32f2f;
}

.ticket-item.priority-high {
    border-left: 3px solid #f57c00;
}

.ticket-item.priority-normal {
    border-left: 3px solid #1976d2;
}

.ticket-item.priority-low {
    border-left: 3px solid #2e7d32;
}