/* =========================================
   1. CONTENEDOR PRINCIPAL
   ========================================= */
.ic-wrapper {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    border: 1px solid #e2e4e7;
    border-radius: 8px;
    padding: 25px;
    background: #fff;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
    position: relative;
    max-width: 100%;
    box-sizing: border-box;
}

.ic-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
    margin-bottom: 20px;
}
.ic-header h3 { margin: 0; color: #333; font-size: 1.2rem; display: flex; align-items: center; gap: 8px;}

/* =========================================
   2. TABS
   ========================================= */
.ic-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 25px;
    border-bottom: 2px solid #eee;
}
.ic-tab-btn {
    background: transparent;
    border: none;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
    margin-bottom: -2px;
}
.ic-tab-btn:hover { color: #0073aa; background: #f8f9fa; }
.ic-tab-btn.active { color: #0073aa; border-bottom: 3px solid #0073aa; background: #fff; }

/* =========================================
   3. CONTROLES Y FILTROS
   ========================================= */
.ic-controls {
    display: grid;
    grid-template-columns: 2fr 2fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
    align-items: center;
}

.ic-control-group input[type="text"] {
    width: 100%;
    padding: 0 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    height: 42px;
    line-height: 40px;
    box-sizing: border-box;
}

/* DROPDOWN CATEGORÍAS */
.ic-custom-select { position: relative; user-select: none; width: 100%; }
.ic-select-trigger {
    background: #fff; border: 1px solid #ccc; border-radius: 6px; padding: 0 15px;
    height: 42px; display: flex; justify-content: space-between; align-items: center;
    cursor: pointer; color: #555; font-size: 14px; box-sizing: border-box;
}
.ic-select-options {
    position: absolute; top: 105%; left: 0; right: 0; background: #fff;
    border: 1px solid #ccc; border-radius: 6px; box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    max-height: 300px; overflow-y: auto; z-index: 9999; display: none; padding: 10px;
}
.ic-custom-select.open .ic-select-options { display: block; }
.ic-option { display: flex; align-items: center; padding: 8px 10px; cursor: pointer; border-radius: 4px; margin-bottom: 2px; }
.ic-option:hover { background: #f0f7fb; }
.ic-option input { margin-right: 10px; }

/* =========================================
   4. BOTONES
   ========================================= */
.ic-btn {
    padding: 0 15px; height: 42px; border: none; border-radius: 6px; cursor: pointer;
    font-weight: 600; transition: all 0.2s; display: inline-flex; align-items: center;
    justify-content: center; gap: 8px; font-size: 13px; text-decoration: none; white-space: nowrap;
}
.ic-btn-primary { background: #0073aa; color: #fff; }
.ic-btn-success { background: #008a20; color: #fff; }
.ic-btn-warning { background: #f39c12; color: #fff; }
.ic-btn:disabled { background: #ccc !important; cursor: not-allowed; color: #fff; }

.ic-actions-bar {
    display: flex; justify-content: space-between; align-items: center;
    background: #f8f9fa; padding: 15px; border-radius: 6px; margin-bottom: 20px; border: 1px solid #eee;
}

/* =========================================
   5. GRID DE PRODUCTOS
   ========================================= */
.ic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(125px, 1fr));
    gap: 15px;
    min-height: 200px;
}

.ic-product-card {
    border: 1px solid #eee;
    padding: 10px;
    border-radius: 6px;
    text-align: center;
    transition: transform 0.2s;
    background: #fff;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.ic-product-card.selected { border-color: #0073aa; background: #f0f7fb; box-shadow: 0 0 0 1px #0073aa; }
.ic-product-card:hover { transform: translateY(-3px); box-shadow: 0 5px 15px rgba(0,0,0,0.08); }

.ic-product-card input[type="checkbox"] {
    transform: scale(1.1); position: absolute; top: 8px; left: 8px; cursor: pointer; z-index: 10;
}

.ic-product-card img {
    width: 100%; height: 120px;
    object-fit: contain; margin-bottom: 8px;
}

.ic-product-card h4 {
    font-size: 12px;
    color: #333; margin: 0 0 5px; height: 32px; overflow: hidden; line-height: 1.3;
}

.ic-product-card .sku { font-size: 10px; color: #888; display: block; margin-bottom: 2px; }
.ic-product-card .price { color: #d32f2f; font-weight: bold; font-size: 12px; display: block; }

/* LOADING */
.ic-loading-wrapper {
    grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 60px 0; color: #0073aa; font-weight: 500;
}
.ic-spinner {
    width: 50px; height: 50px; border: 5px solid #f3f3f3; border-top: 5px solid #0073aa;
    border-radius: 50%; animation: ic-spin 1s linear infinite; margin-bottom: 15px;
}
@keyframes ic-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.ic-fade-in { animation: fadeIn 0.3s ease-in-out; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* =========================================
   6. HISTORIAL Y EMAIL (CORREGIDO)
   ========================================= */
.ic-history-wrapper .ic-table { width: 100%; border-collapse: collapse; }
.ic-history-wrapper th, .ic-history-wrapper td { padding: 12px; border-bottom: 1px solid #eee; text-align: left; }
.ic-history-wrapper th { background: #f1f1f1; font-weight: 600; }

.ic-email-bar {
    margin-top: 20px; 
    background: #f0f7fb; 
    padding: 15px;
    border-radius: 6px; 
    border: 1px solid #cce5ff; 
    display: flex; 
    gap: 15px; 
    align-items: center; 
    justify-content: flex-end;
}

.ic-email-input-group { 
    position: relative; 
    flex-grow: 1; 
    max-width: 400px; 
}

/* FIX ICONO SUPERPUESTO */
.ic-email-input-group .dashicons { 
    position: absolute; 
    left: 12px; 
    top: 50%; 
    transform: translateY(-50%); 
    color: #0073aa;
    z-index: 10;
    pointer-events: none;
}

/* FIX TEXTO INPUT */
.ic-email-input-group input { 
    width: 100%; 
    /* Padding Left aumentado y forzado para que el texto no toque el icono */
    padding: 10px 10px 10px 45px !important; 
    border: 1px solid #b3d7ff; 
    border-radius: 4px; 
    box-sizing: border-box;
    height: 42px;
}

.ic-selected-counter { background: #e8f0fe; color: #1a73e8; padding: 4px 10px; border-radius: 20px; font-size: 0.85rem; font-weight: 600; }
#ic-pagination { text-align: center; margin-top: 30px; }

/* =========================================
   7. RESPONSIVE MOBILE FIXES
   ========================================= */
@media (max-width: 768px) {
    .ic-controls { grid-template-columns: 1fr; }
    
    .ic-tabs { flex-direction: column; border-bottom: none; }
    .ic-tab-btn { width: 100%; text-align: left; border-bottom: 1px solid #eee; }
    .ic-tab-btn.active { border-left: 4px solid #0073aa; border-bottom: 1px solid #eee; background: #f0f7fb; }
    
    .ic-actions-bar { flex-direction: column; align-items: flex-start; gap: 10px; }
    .ic-btn, #ic-filter-btn { width: 100%; }
    
    .ic-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
    
    .ic-email-bar { flex-direction: column; }
    .ic-email-input-group { width: 100%; max-width: none; }

    /* --- MOBILE HISTORY TABLE (CARD VIEW) --- */
    .ic-history-wrapper {
        border: none; padding: 0; background: transparent; box-shadow: none;
    }
    .ic-history-wrapper .ic-header {
        background: #fff; padding: 15px; border-radius: 8px; border: 1px solid #eee;
        flex-direction: column; align-items: stretch; gap: 10px;
    }
    .ic-history-wrapper .ic-table,
    .ic-history-wrapper thead,
    .ic-history-wrapper tbody,
    .ic-history-wrapper th,
    .ic-history-wrapper td,
    .ic-history-wrapper tr {
        display: block; 
    }
    .ic-history-wrapper thead { display: none; }
    .ic-history-wrapper tr {
        background: #fff; border: 1px solid #e1e1e1; border-radius: 8px;
        margin-bottom: 15px; padding: 15px 15px 15px 50px; position: relative;
        box-shadow: 0 2px 5px rgba(0,0,0,0.03);
    }
    .ic-history-wrapper td { border: none; padding: 5px 0; text-align: left; }
    .ic-history-wrapper td:first-child { position: absolute; top: 15px; left: 15px; padding: 0; }
    .ic-history-wrapper td:first-child input { transform: scale(1.4); }
    .ic-history-wrapper td:nth-of-type(2):before { content: "Fecha: "; font-weight: 600; color: #777; font-size: 0.9em; }
    .ic-history-wrapper td:nth-of-type(3):before { content: "Formato: "; font-weight: 600; color: #777; font-size: 0.9em; }
    .ic-history-wrapper td:nth-of-type(4) {
        font-weight: 700; color: #0073aa; font-size: 1.1em;
        padding-bottom: 10px; margin-bottom: 10px; border-bottom: 1px dashed #eee;
        word-break: break-word;
    }
    .ic-history-wrapper td:last-child { display: flex; gap: 10px; }
    .ic-history-wrapper td:last-child .ic-btn { flex: 1; }
}