/* ============================================================================
 * iswPuertas · Sprint 2 · Modal de Pagos (cobros + anticipos)
 * Prefix: isw-pm-
 * ============================================================================ */

.isw-pm-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 100009;
    display: none;
}
.isw-pm-backdrop.open { display: block; }

.isw-pm-modal {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 92vw; max-width: 980px;
    max-height: 92vh;
    background: #fff;
    box-shadow: 0 18px 60px rgba(0,0,0,0.45);
    z-index: 100009;
    display: none;
    flex-direction: column;
    overflow: hidden;
    border-top: 4px solid #f39c12;
}
.isw-pm-modal.open { display: flex; }

.isw-pm-header {
    background: linear-gradient(135deg, #1a252f 0%, #2c3e50 100%);
    color: #fff;
    padding: 12px 18px;
    display: flex; align-items: center; gap: 12px;
    border-bottom: 3px solid #f39c12;
}
.isw-pm-header h2 {
    margin: 0; font-size: 16px; font-weight: 700; letter-spacing: 0.4px;
    flex: 1;
}
.isw-pm-header .isw-pm-sub {
    font-size: 11px; opacity: 0.85;
}
.isw-pm-close {
    background: rgba(255,255,255,0.12);
    color: #fff; border: 1px solid rgba(255,255,255,0.3);
    padding: 6px 12px; font-weight: 700; font-size: 12px;
    cursor: pointer;
}
.isw-pm-close:hover { background: rgba(255,255,255,0.22); }

.isw-pm-kpis {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 0; background: #f8f9fa;
    border-bottom: 1px solid #ddd;
}
.isw-pm-kpi {
    padding: 10px 14px;
    text-align: center;
    border-right: 1px solid #e0e0e0;
}
.isw-pm-kpi:last-child { border-right: none; }
.isw-pm-kpi-label {
    font-size: 10px; color: #7f8c8d; text-transform: uppercase;
    letter-spacing: 0.6px; font-weight: 700;
}
.isw-pm-kpi-value {
    font-size: 20px; font-weight: 700; margin-top: 4px;
}
.isw-pm-kpi.total .isw-pm-kpi-value    { color: #2c3e50; }
.isw-pm-kpi.cobrado .isw-pm-kpi-value  { color: #27ae60; }
.isw-pm-kpi.pendiente .isw-pm-kpi-value{ color: #e74c3c; }

.isw-pm-body {
    flex: 1; overflow-y: auto;
    padding: 0;
}

.isw-pm-section {
    padding: 14px 18px;
    border-bottom: 1px solid #ececec;
}
.isw-pm-section h3 {
    margin: 0 0 8px 0;
    font-size: 13px; color: #2c3e50;
    border-left: 4px solid #f39c12; padding-left: 8px;
    text-transform: uppercase; letter-spacing: 0.4px;
}

.isw-pm-table {
    width: 100%; border-collapse: collapse; font-size: 12px;
}
.isw-pm-table th {
    background: #2c3e50; color: #fff;
    padding: 6px 8px; text-align: left;
    font-size: 11px; font-weight: 700; letter-spacing: 0.4px;
    text-transform: uppercase;
}
.isw-pm-table td {
    padding: 8px; border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}
.isw-pm-table tr:hover { background: #fafbfc; }
.isw-pm-empty {
    text-align: center; padding: 24px;
    color: #95a5a6; font-style: italic;
}

.isw-pm-badge {
    display: inline-block; padding: 2px 8px;
    font-size: 10px; font-weight: 700; color: #fff;
    letter-spacing: 0.4px; text-transform: uppercase;
}
.isw-pm-badge.b-anticipo   { background: #9b59b6; }
.isw-pm-badge.b-cobro      { background: #27ae60; }
.isw-pm-badge.b-devolucion { background: #e74c3c; }
.isw-pm-badge.b-aplicacion { background: #3498db; }
.isw-pm-badge.b-aplicado   { background: #95a5a6; }

.isw-pm-importe {
    font-weight: 700; font-family: 'Courier New', monospace;
}
.isw-pm-importe.neg { color: #e74c3c; }
.isw-pm-importe.pos { color: #27ae60; }

.isw-pm-action {
    background: none; border: none;
    color: #34495e; cursor: pointer;
    padding: 4px 6px; font-size: 13px;
}
.isw-pm-action:hover { color: #2c3e50; background: #ecf0f1; }
.isw-pm-action.danger:hover { color: #e74c3c; }

/* Form nuevo cobro */
.isw-pm-form {
    background: #fffbf3;
    border: 1px solid #f9e2b6;
    padding: 14px;
    display: grid; gap: 10px;
    grid-template-columns: repeat(4, 1fr);
}
.isw-pm-form .full { grid-column: 1 / -1; }
.isw-pm-form label {
    display: block; font-size: 10px;
    color: #7f8c8d; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.4px;
    margin-bottom: 3px;
}
.isw-pm-form input, .isw-pm-form select, .isw-pm-form textarea {
    width: 100%; padding: 6px 8px; font-size: 12px;
    border: 1px solid #ccc; background: #fff;
    font-family: inherit;
}
.isw-pm-form textarea { min-height: 50px; resize: vertical; }
.isw-pm-form .checkbox-row {
    display: flex; align-items: center; gap: 8px;
    font-size: 12px; color: #2c3e50; font-weight: 700;
}
.isw-pm-form .checkbox-row input { width: auto; }

.isw-pm-form-actions {
    display: flex; gap: 8px; justify-content: flex-end;
    grid-column: 1 / -1;
}
.isw-pm-btn {
    background: #2c3e50; color: #fff; border: none;
    padding: 8px 16px; font-size: 12px; font-weight: 700;
    cursor: pointer; letter-spacing: 0.4px; text-transform: uppercase;
}
.isw-pm-btn:hover { background: #1a252f; }
.isw-pm-btn.primary { background: #27ae60; }
.isw-pm-btn.primary:hover { background: #229954; }
.isw-pm-btn.warn { background: #f39c12; }
.isw-pm-btn.warn:hover { background: #e67e22; }
.isw-pm-btn.danger { background: #e74c3c; }
.isw-pm-btn.danger:hover { background: #c0392b; }
.isw-pm-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Toggle form */
.isw-pm-form-toggle {
    text-align: center; padding: 10px;
    background: #ecf0f1; cursor: pointer;
    font-weight: 700; color: #2c3e50;
    font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px;
    border-bottom: 1px solid #ddd;
}
.isw-pm-form-toggle:hover { background: #d5dbdb; }

/* Mini modal envio */
.isw-pm-send {
    position: fixed; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 420px; max-width: 92vw;
    background: #fff; box-shadow: 0 12px 40px rgba(0,0,0,0.4);
    z-index: 100009; display: none;
    border-top: 3px solid #f39c12;
}
.isw-pm-send.open { display: block; }
.isw-pm-send .h {
    background: #1a252f; color: #fff;
    padding: 10px 14px; font-weight: 700; font-size: 13px;
    display: flex; justify-content: space-between;
}
.isw-pm-send .b { padding: 16px; }
.isw-pm-send label { display: block; font-size: 10px; color: #7f8c8d; font-weight: 700; margin-bottom: 4px; text-transform: uppercase; }
.isw-pm-send input { width: 100%; padding: 8px; font-size: 13px; border: 1px solid #ccc; margin-bottom: 12px; }
.isw-pm-send .a { display: flex; gap: 8px; justify-content: flex-end; }

/* Toast */
.isw-pm-toast {
    position: fixed; bottom: 24px; left: 50%;
    transform: translateX(-50%);
    background: #2c3e50; color: #fff;
    padding: 12px 22px; font-size: 13px; font-weight: 700;
    z-index: 100009; display: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.isw-pm-toast.show { display: block; }
.isw-pm-toast.ok  { background: #27ae60; }
.isw-pm-toast.bad { background: #e74c3c; }

@media (max-width: 720px) {
    .isw-pm-form { grid-template-columns: repeat(2, 1fr); }
    .isw-pm-kpi-value { font-size: 16px; }
    .isw-pm-header h2 { font-size: 13px; }
}


/* ISW_ZINDEX_OVERRIDE_v2 */
/* Forzar pago modal por encima del doc modal (z-index 99999) */
#isw-pago-modal,
#isw-pago-overlay,
#isw-pm-form-fecha,
#isw-pm-form-fkmode,
#isw-pm-form-importe,
#isw-pm-form-notas,
#isw-pm-form-recibo,
#isw-pm-form-ref,
#isw-pm-form-save,
#isw-pm-form-toggle,
#isw-pm-form-wrap,
#isw-pm-kpi-cobrado,
#isw-pm-kpi-pendiente,
#isw-pm-kpi-total,
#isw-pm-launch-btn,
#isw-pm-modal,
#isw-pm-overlay,
#isw-pm-send,
#isw-pm-send-cancel,
#isw-pm-send-close,
#isw-pm-send-input,
#isw-pm-send-ok,
#isw-pm-sub,
#isw-pm-tbody,
#isw-pm-title,
.isw-pago-modal,
.isw-pago-overlay,
.isw-pm-action,
.isw-pm-backdrop,
.isw-pm-badge,
.isw-pm-body,
.isw-pm-btn,
.isw-pm-close,
.isw-pm-empty,
.isw-pm-form,
.isw-pm-form-actions,
.isw-pm-form-toggle,
.isw-pm-header,
.isw-pm-importe,
.isw-pm-kpi,
.isw-pm-kpi-label,
.isw-pm-kpi-value,
.isw-pm-kpis,
.isw-pm-modal,
.isw-pm-overlay,
.isw-pm-section,
.isw-pm-send-modal,
.isw-pm-sub,
.isw-pm-table,
.isw-pm-toast {
    z-index: 200000 !important;
    pointer-events: auto !important;
}
